From f902156528bc763133e6b5fe96e162bc2d5a1a6e Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sun, 9 Jun 2024 10:09:54 -0400 Subject: [PATCH] 3.8.0 --- Arkham SCE.json | 4353 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 3785 insertions(+), 568 deletions(-) diff --git a/Arkham SCE.json b/Arkham SCE.json index a5d5cfc..78882ac 100644 --- a/Arkham SCE.json +++ b/Arkham SCE.json @@ -135,36 +135,11 @@ ] }, "CustomUIAssets": [ - { - "Name": "refresh", - "Type": 0, - "URL": "http://cloud-3.steamusercontent.com/ugc/1695031152736214852/EC3BBEF1A1788381A8F4C5ACB7FB27770CAF03C5/" - }, { "Name": "close", "Type": 0, "URL": "http://cloud-3.steamusercontent.com/ugc/1695031152736214756/2EEB07E453A7ECF4BE5A1030A253185B37A7CDAB/" }, - { - "Name": "cthulhu", - "Type": 0, - "URL": "http://cloud-3.steamusercontent.com/ugc/1782854877010107768/BC6A97F193385D01C1A9149B68923F55A284CB2D/" - }, - { - "Name": "dark-cult", - "Type": 0, - "URL": "http://cloud-3.steamusercontent.com/ugc/1782854877010108105/08594607341D6537C28A08A34CE82159025AB8DB/" - }, - { - "Name": "yog-sothoth", - "Type": 0, - "URL": "http://cloud-3.steamusercontent.com/ugc/1782854877010107124/D8042D1A1B08CFB7E76488B09216B4611D85A2B9/" - }, - { - "Name": "elder-sign", - "Type": 0, - "URL": "http://cloud-3.steamusercontent.com/ugc/1782854877010107442/43BC029410751208A90AE7FDEBCB587A0E9403D7/" - }, { "Name": "devourer", "Type": 0, @@ -191,35 +166,25 @@ "URL": "http://cloud-3.steamusercontent.com/ugc/2026086584372569912/5CB461AEAE2E59D3064D90A776EB86C46081EC78/" }, { - "Name": "font_birmingham", - "Type": 1, - "URL": "http://cloud-3.steamusercontent.com/ugc/2027213118466443497/3CF9BB9AF968D245961494CC9A151774EB9BA638/" + "Name": "option-on", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/" }, { - "Name": "font_columbus", - "Type": 1, - "URL": "http://cloud-3.steamusercontent.com/ugc/2027213118466515872/F473E4ACC75ACB6CE07457C45290B4912E0B3286/" + "Name": "option-off", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/" }, { - "Name": "font_oldremington", + "Name": "font_arkhamicons", "Type": 1, - "URL": "http://cloud-3.steamusercontent.com/ugc/2027213118466515932/AFCE53F1E1D9580D166F53AD9EB0D77A331D4A26/" + "URL": "http://cloud-3.steamusercontent.com/ugc/2462982115649258367/C20CC4C299A6FE5F1ECAB968E15BE590337CC019/" }, { "Name": "font_teutonic-arkham", "Type": 1, "URL": "http://cloud-3.steamusercontent.com/ugc/2027213118467703445/89328E273B4C5180BF491516CE998DE3C604E162/" }, - { - "Name": "font_uglyqua", - "Type": 1, - "URL": "http://cloud-3.steamusercontent.com/ugc/2027213118466516005/113C19D37CFFA9E554394FD5B11B32967F846A62/" - }, - { - "Name": "font_chinese_fzlibian", - "Type": 1, - "URL": "http://cloud-3.steamusercontent.com/ugc/2028355502896482829/8DAB311590B97586309E66D795AC2C43D4913188/" - }, { "Name": "header_cover", "Type": 0, @@ -255,11 +220,6 @@ "Type": 0, "URL": "https://i.imgur.com/6MReiEO.png" }, - { - "Name": "Inv-Roland", - "Type": 0, - "URL": "https://i.imgur.com/lx6unDY.png" - }, { "Name": "NextArrow", "Type": 0, @@ -270,6 +230,11 @@ "Type": 0, "URL": "https://i.imgur.com/8qmTXwt.png" }, + { + "Name": "Inv-Roland", + "Type": 0, + "URL": "https://i.imgur.com/lx6unDY.png" + }, { "Name": "Inv-Mandy", "Type": 0, @@ -374,9 +339,54 @@ "Name": "box-cover-mask-wide", "Type": 0, "URL": "http://cloud-3.steamusercontent.com/ugc/2115061298538827369/A20C2ECB8ECDC1B0AD8B2B38F68CA1C1F5E07D37/" + }, + { + "Name": "token-skull", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2380784374775547231/E0FEEF462DE4E7704832CA2415D0D027A6BF5041/" + }, + { + "Name": "token-bless", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2380784374775547028/7855033DE0EB1FDDF706E1303054D35FE0902532/" + }, + { + "Name": "token-curse", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2380784374775547135/2360372CBE9452CB7B4D135BE13BBA6D46B7D427/" + }, + { + "Name": "token-cultist", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2380784374792650461/10D8037632900AA86045BDD42A564716D5855B1B/" + }, + { + "Name": "token-tablet", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2380784374792650857/29DAE514E5C838C24C90ABBFFF92B1359B9A2F76/" + }, + { + "Name": "token-elder-thing", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2380784374792650683/1C046B6335317CA1AEBFC80645EEC18852D83D80/" + }, + { + "Name": "token-frost", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2380784374792650766/73E07A50BE6FD9BED266F3421B472C4BF913DE81/" + }, + { + "Name": "token-auto-fail", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2510267932886739653/CB7AA2D73777EF5938A6E6CD664B2ABA52B6E20A/" + }, + { + "Name": "token-custom-token", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2380784374792650571/E4C2B2B69282A4EE15FE290FF6B08BEFC8FCA65C/" } ], - "Date": "Mon Mar 4 23:52:37 CET 2024", + "Date": "Sun May 12 13:10:46 CEST 2024", "DecalPallet": [ { "ImageURL": "http://cloud-3.steamusercontent.com/ugc/1474319121424323663/BC5570ECF747F1B30224461B576E8B0FE7FA5F33/", @@ -390,7 +400,7 @@ } ], "Decals": [], - "EpochTime": 1709592757, + "EpochTime": 1715512246, "GameComplexity": "", "GameMode": "Arkham Horror LCG - Super Complete Edition", "GameType": "", @@ -449,7 +459,7 @@ "LutIndex": 0, "ReflectionIntensity": 1 }, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/Global\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/Global\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal navigationOverlayApi = require(\"core/NavigationOverlayApi\")\nlocal playAreaApi = require(\"core/PlayAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal soundCubeApi = require(\"core/SoundCubeApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\nlocal tokenChecker = require(\"core/token/TokenChecker\")\nlocal tokenManager = require(\"core/token/TokenManager\")\n\n---------------------------------------------------------\n-- general setup\n---------------------------------------------------------\n\nENCOUNTER_DECK_POS = { -3.93, 1, 5.76 }\nENCOUNTER_DECK_DISCARD_POSITION = { -3.85, 1, 10.38 }\n\n-- GUIDs that will not be interactable (e.g. parts of the table)\nlocal NOT_INTERACTABLE = {\n \"6161b4\", -- Decoration-Map\n \"9f334f\", -- MythosArea\n \"463022\", -- Panel behind tentacle stand\n \"f182ee\", -- InvestigatorCount\n \"7bff34\", -- Tentacle stand\n \"8646eb\", -- horizontal border left\n \"75937e\", -- horizontal border right\n \"612072\", -- vertical border left\n \"975c39\", -- vertical border right\n}\n\nlocal chaosTokens = {}\nlocal chaosTokensLastMatGUID = nil\n\n-- chaos token stat tracking\nlocal tokenDrawingStats = { [\"Overall\"] = {} }\n\nlocal bagSearchers = {}\nlocal hideTitleSplashWaitFunctionId = nil\n\n-- online functionality related variables\nlocal MOD_VERSION = \"3.7.0\"\nlocal SOURCE_REPO = 'https://raw.githubusercontent.com/chr1z93/loadable-objects/main'\nlocal library, requestObj, modMeta\nlocal acknowledgedUpgradeVersions = {}\nlocal contentToShow = \"campaigns\"\nlocal currentListItem = 1\nlocal tabIdTable = {\n tab1 = \"campaigns\",\n tab2 = \"scenarios\",\n tab3 = \"fanmadeCampaigns\",\n tab4 = \"fanmadeScenarios\",\n tab5 = \"fanmadePlayerCards\"\n}\n\n-- optionPanel data\noptionPanel = {}\nlocal LANGUAGES = {\n { code = \"zh_CN\", name = \"简体中文\" },\n { code = \"zh_TW\", name = \"繁體中文\" },\n { code = \"de\", name = \"Deutsch\" },\n { code = \"en\", name = \"English\" },\n { code = \"es\", name = \"Español\" },\n { code = \"fr\", name = \"Français\" },\n { code = \"it\", name = \"Italiano\" }\n}\nlocal RESOURCE_OPTIONS = {\n \"enabled\",\n \"custom\",\n \"disabled\"\n}\n\n---------------------------------------------------------\n-- data for tokens\n---------------------------------------------------------\n\nTOKEN_DATA = {\n damage = {image = \"http://cloud-3.steamusercontent.com/ugc/1758068501357115146/903D11AAE7BD5C254C8DC136E9202EE516289DEA/\", scale = {0.17, 0.17, 0.17}},\n horror = {image = \"http://cloud-3.steamusercontent.com/ugc/1758068501357163535/6D9E0756503664D65BDB384656AC6D4BD713F5FC/\", scale = {0.17, 0.17, 0.17}},\n resource = {image = \"http://cloud-3.steamusercontent.com/ugc/1758068501357192910/11DDDC7EF621320962FDCF3AE3211D5EDC3D1573/\", scale = {0.17, 0.17, 0.17}},\n doom = {image = \"https://i.imgur.com/EoL7yaZ.png\", scale = {0.17, 0.17, 0.17}},\n clue = {image = \"http://cloud-3.steamusercontent.com/ugc/1758068501357164917/1D06F1DC4D6888B6F57124BD2AFE20D0B0DA15A8/\", scale = {0.15, 0.15, 0.15}}\n}\n\nID_URL_MAP = {\n ['blue'] = {name = \"Elder Sign\", url = 'https://i.imgur.com/nEmqjmj.png'},\n ['p1'] = {name = \"+1\", url = 'https://i.imgur.com/uIx8jbY.png'},\n ['0'] = {name = \"0\", url = 'https://i.imgur.com/btEtVfd.png'},\n ['m1'] = {name = \"-1\", url = 'https://i.imgur.com/w3XbrCC.png'},\n ['m2'] = {name = \"-2\", url = 'https://i.imgur.com/bfTg2hb.png'},\n ['m3'] = {name = \"-3\", url = 'https://i.imgur.com/yfs8gHq.png'},\n ['m4'] = {name = \"-4\", url = 'https://i.imgur.com/qrgGQRD.png'},\n ['m5'] = {name = \"-5\", url = 'https://i.imgur.com/3Ym1IeG.png'},\n ['m6'] = {name = \"-6\", url = 'https://i.imgur.com/c9qdSzS.png'},\n ['m7'] = {name = \"-7\", url = 'https://i.imgur.com/4WRD42n.png'},\n ['m8'] = {name = \"-8\", url = 'https://i.imgur.com/9t3rPTQ.png'},\n ['skull'] = {name = \"Skull\", url = 'https://i.imgur.com/stbBxtx.png'},\n ['cultist'] = {name = \"Cultist\", url = 'https://i.imgur.com/VzhJJaH.png'},\n ['tablet'] = {name = \"Tablet\", url = 'https://i.imgur.com/1plY463.png'},\n ['elder'] = {name = \"Elder Thing\", url = 'https://i.imgur.com/ttnspKt.png'},\n ['red'] = {name = \"Auto-fail\", url = 'https://i.imgur.com/lns4fhz.png'},\n ['bless'] = {name = \"Bless\", url = 'http://cloud-3.steamusercontent.com/ugc/1655601092778627699/339FB716CB25CA6025C338F13AFDFD9AC6FA8356/'},\n ['curse'] = {name = \"Curse\", url = 'http://cloud-3.steamusercontent.com/ugc/1655601092778636039/2A25BD38E8C44701D80DD96BF0121DA21843672E/'},\n\t['frost'] = {name = \"Frost\", url = 'http://cloud-3.steamusercontent.com/ugc/1858293462583104677/195F93C063A8881B805CE2FD4767A9718B27B6AE/'}\n}\n\n---------------------------------------------------------\n-- general code\n---------------------------------------------------------\n\n-- saving state of optionPanel to restore later\nfunction onSave()\n local chaosTokensGUID = {}\n for _, obj in ipairs(chaosTokens) do\n if obj ~= nil then\n table.insert(chaosTokensGUID, obj.getGUID())\n end\n end\n\n return JSON.encode({\n optionPanel = optionPanel,\n acknowledgedUpgradeVersions = acknowledgedUpgradeVersions,\n chaosTokensLastMatGUID = chaosTokensLastMatGUID,\n chaosTokensGUID = chaosTokensGUID\n })\nend\n\nfunction onLoad(savedData)\n if savedData then\n loadedData = JSON.decode(savedData)\n optionPanel = loadedData.optionPanel\n acknowledgedUpgradeVersions = loadedData.acknowledgedUpgradeVersions\n updateOptionPanelState()\n\n -- restore saved state for drawn chaos tokens\n for _, guid in ipairs(loadedData.chaosTokensGUID or {}) do\n table.insert(chaosTokens, getObjectFromGUID(guid))\n end\n chaosTokensLastMatGUID = loadedData.chaosTokensLastMatGUID\n else\n print(\"Saved state could not be found!\")\n end\n\n for _, guid in ipairs(NOT_INTERACTABLE) do\n local obj = getObjectFromGUID(guid)\n if obj ~= nil then obj.interactable = false end\n end\n\n getModVersion()\n math.randomseed(os.time())\n\n -- initialization of loadable objects library (delay to let Navigation Overlay build)\n Wait.time(function()\n WebRequest.get(SOURCE_REPO .. '/library.json', libraryDownloadCallback)\n end, 1)\nend\n\n-- Event hook for any object search. When chaos tokens are manipulated while the chaos bag\n-- container is being searched, a TTS bug can cause tokens to duplicate or vanish. We lock the\n-- chaos bag during search operations to avoid this.\nfunction onObjectSearchStart(object, playerColor)\n local chaosBag = findChaosBag()\n if object == chaosBag then\n bagSearchers[playerColor] = true\n end\nend\n\n-- Event hook for any object search. When chaos tokens are manipulated while the chaos bag\n-- container is being searched, a TTS bug can cause tokens to duplicate or vanish. We lock the\n-- chaos bag during search operations to avoid this.\nfunction onObjectSearchEnd(object, playerColor)\n local chaosBag = findChaosBag()\n if object == chaosBag then\n bagSearchers[playerColor] = nil\n end\nend\n\n-- Pass object enter container events to the PlayArea to clear vector lines from dragged cards.\n-- This requires the try method as cards won't exist any more after they enter a deck, so the lines\n-- can't be cleared.\nfunction tryObjectEnterContainer(container, object)\n playAreaApi.tryObjectEnterContainer(container, object)\n return true\nend\n\n-- TTS event for objects that enter zones\n-- used to detect the \"token discard zones\" beneath the hand zones\nfunction onObjectEnterZone(zone, enteringObj)\n if zone.getName() ~= \"TokenDiscardZone\" then return end\n if tokenChecker.isChaosToken(enteringObj) then return end\n \n if enteringObj.type == \"Tile\" and enteringObj.getMemo() and enteringObj.getLock() == false then\n local matcolor = playmatApi.getMatColorByPosition(enteringObj.getPosition())\n local trash = guidReferenceApi.getObjectByOwnerAndType(matcolor, \"Trash\")\n trash.putObject(enteringObj)\n end\nend\n\n-- handle card drawing via number typing for multihanded gameplay\n-- (and additionally allow Norman Withers to draw multiple cards via number)\nfunction onObjectNumberTyped(hoveredObject, playerColor, number)\n -- only continue for decks or cards\n if hoveredObject.type ~= \"Deck\" and hoveredObject.type ~= \"Card\" then return end\n \n -- check whether the hovered object is part of a players draw objects\n for _, color in ipairs(playmatApi.getUsedMatColors()) do\n local deckAreaObjects = playmatApi.getDeckAreaObjects(color)\n if deckAreaObjects.topCard == hoveredObject or deckAreaObjects.draw == hoveredObject then\n playmatApi.drawCardsWithReshuffle(color, number)\n return true\n end\n end\nend\n\n---------------------------------------------------------\n-- chaos token drawing\n---------------------------------------------------------\n\n-- checks scripting zone for chaos bag (also called by a lot of objects!)\nfunction findChaosBag()\n local chaosBagZone = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"ChaosBagZone\")\n\n -- error handling: scripting zone not found\n if chaosBagZone == nil then\n printToAll(\"Zone for chaos bag detection couldn't be found.\", \"Red\")\n return\n end\n\n for _, item in ipairs(chaosBagZone.getObjects()) do\n if item.getDescription() == \"Chaos Bag\" then\n return item\n end\n end\n\n -- error handling: chaos bag not found\n printToAll(\"Chaos bag couldn't be found.\", \"Red\")\nend\n\nfunction returnChaosTokens()\n local chaosBag = findChaosBag()\n for _, token in pairs(chaosTokens) do\n if token ~= nil then chaosBag.putObject(token) end\n end\n chaosTokens = {}\nend\n\n-- returns a single chaos token to the bag and calls respective functions\nfunction returnChaosTokenToBag(token)\n local name = token.getName()\n local guid = token.getGUID()\n local chaosBag = findChaosBag()\n chaosBag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n-- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n-- contents of the bag should check this method before doing so.\n-- This method will broadcast a message to all players if the bag is being searched.\n---@return boolean: True if the bag is manipulated, false if it should be blocked.\nfunction canTouchChaosTokens()\n for color, searching in pairs(bagSearchers) do\n if searching then\n broadcastToAll(\"Someone is searching the chaos bag, can't touch the tokens.\", \"Red\")\n return false\n end\n end\n return true\nend\n\n-- called by playermats (by the \"Draw chaos token\" button)\nfunction drawChaosToken(params)\n if not canTouchChaosTokens() then return end\n\n local tokenOffset = {-1.55, 0.25, -0.58}\n local matGUID = params.mat.getGUID()\n\n -- return token(s) on other playmat first\n if chaosTokensLastMatGUID ~= nil and chaosTokensLastMatGUID ~= matGUID and #chaosTokens ~= 0 then\n returnChaosTokens()\n chaosTokensLastMatGUID = nil\n return\n end\n\n chaosTokensLastMatGUID = matGUID\n\n -- if we have left clicked and have no tokens OR if we have right clicked\n if params.drawAdditional or #chaosTokens == 0 then\n local chaosBag = findChaosBag()\n if #chaosBag.getObjects() == 0 then return end\n chaosBag.shuffle()\n\n -- add the token to the list, compute new position based on list length\n tokenOffset[1] = tokenOffset[1] + (0.17 * #chaosTokens)\n \n local token\n\n if params.guidToBeResolved then -- resolve a sealed token from a card\n token = getObjectFromGUID(params.guidToBeResolved)\n token.setPositionSmooth(params.mat.positionToWorld(tokenOffset))\n local guid = token.getGUID()\n local tokenType = token.getName()\n if tokenType == \"Bless\" or tokenType == \"Curse\" then\n blessCurseManagerApi.releasedToken(tokenType, guid)\n end\n tokenArrangerApi.layout()\n else -- take a token from the bag, either specified or random\n local takeParameters = {\n position = params.mat.positionToWorld(tokenOffset),\n rotation = params.mat.getRotation()\n }\n\n if params.tokenType then\n for i, lookedForToken in ipairs(chaosBag.getObjects()) do\n if lookedForToken.name == params.tokenType then\n takeParameters.index = i - 1\n end\n end\n end\n\n token = chaosBag.takeObject(takeParameters)\n end \n -- get data for token description\n local name = token.getName()\n local tokenData = mythosAreaApi.returnTokenData().tokenData or {}\n local specificData = tokenData[name] or {}\n token.setDescription(specificData.description or \"\")\n\n -- track the chaos token (for stat tracker and future returning)\n trackChaosToken(name, matGUID)\n chaosTokens[#chaosTokens + 1] = token\n else\n returnChaosTokens()\n end\nend\n\n---------------------------------------------------------\n-- token spawning\n---------------------------------------------------------\n\n-- DEPRECATED. Use TokenManager instead.\n-- Spawns a single token.\n---@param params table Array with arguments to the method. 1 = position, 2 = type, 3 = rotation\nfunction spawnToken(params)\n return tokenManager.spawnToken(params[1], params[2], params[3])\nend\n\n---------------------------------------------------------\n-- chaos token stat tracker\n---------------------------------------------------------\n\nfunction trackChaosToken(tokenName, matGUID)\n -- initialize tables\n if not tokenDrawingStats[matGUID] then tokenDrawingStats[matGUID] = {} end\n\n -- increase stats by 1\n tokenDrawingStats[\"Overall\"][tokenName] = (tokenDrawingStats[\"Overall\"][tokenName] or 0) + 1\n tokenDrawingStats[matGUID][tokenName] = (tokenDrawingStats[matGUID][tokenName] or 0) + 1\nend\n\n-- Left-click: print stats, Right-click: reset stats\nfunction handleStatTrackerClick(_, _, isRightClick)\n if isRightClick then\n resetChaosTokenStatTracker()\n else\n local squidKing = \"Nobody\"\n local maxSquid = 0\n local foundAnyStats = false\n\n for key, personalStats in pairs(tokenDrawingStats) do\n local playerColor, playerName\n\n if key == \"Overall\" then\n playerColor = \"White\"\n playerName = \"Overall\"\n else\n -- get mat color\n local matColor = playmatApi.getMatColorByPosition(getObjectFromGUID(key).getPosition())\n playerColor = playmatApi.getPlayerColor(matColor)\n playerName = Player[playerColor].steam_name or playerColor\n\n local playerSquidCount = personalStats[\"Auto-fail\"] or 0\n if playerSquidCount \u003e maxSquid then\n squidKing = playerName\n maxSquid = playerSquidCount\n end\n end\n\n -- get the total count of drawn tokens for the player\n local totalCount = 0\n for tokenName, value in pairs(personalStats) do\n totalCount = totalCount + value\n end\n\n -- only print the personal stats if any tokens were drawn\n if totalCount \u003e 0 then\n foundAnyStats = true\n printToAll(\"------------------------------\")\n printToAll(playerName .. \" Stats\", playerColor)\n\n for tokenName, value in pairs(personalStats) do\n if value ~= 0 then\n printToAll(tokenName .. ': ' .. tostring(value))\n end\n end\n printToAll('Total: ' .. tostring(totalCount))\n end\n end\n\n -- detect if any player drew tokens\n if foundAnyStats then\n printToAll(\"------------------------------\")\n printToAll(squidKing .. \" is an auto-fail magnet.\", { 255, 0, 0 })\n else\n printToAll(\"No tokens have been drawn yet.\", \"Yellow\")\n end\n end\nend\n\n-- resets the count for each token to 0\nfunction resetChaosTokenStatTracker()\n tokenDrawingStats = { [\"Overall\"] = {} }\nend\n\n---------------------------------------------------------\n-- Difficulty selector script\n---------------------------------------------------------\n\n-- called for button creation on the difficulty selectors\n---@param args table Parameters for this function:\n-- object TTSObject Usually \"self\"\n-- key String Name of the scenario\nfunction createSetupButtons(args)\n local data = getDataValue('modeData', args.key)\n if data ~= nil then\n local buttonParameters = {}\n buttonParameters.function_owner = args.object\n buttonParameters.position = { 0, 0.1, -0.15 }\n buttonParameters.scale = { 0.47, 1, 0.47 }\n buttonParameters.height = 200\n buttonParameters.width = 1150\n buttonParameters.color = { 0.87, 0.8, 0.7 }\n\n if data.easy ~= nil then\n buttonParameters.label = \"Easy\"\n buttonParameters.click_function = \"easyClick\"\n args.object.createButton(buttonParameters)\n buttonParameters.position[3] = buttonParameters.position[3] + 0.20\n end\n\n if data.normal ~= nil then\n buttonParameters.label = \"Standard\"\n buttonParameters.click_function = \"normalClick\"\n args.object.createButton(buttonParameters)\n buttonParameters.position[3] = buttonParameters.position[3] + 0.20\n end\n\n if data.hard ~= nil then\n buttonParameters.label = \"Hard\"\n buttonParameters.click_function = \"hardClick\"\n args.object.createButton(buttonParameters)\n buttonParameters.position[3] = buttonParameters.position[3] + 0.20\n end\n\n if data.expert ~= nil then\n buttonParameters.label = \"Expert\"\n buttonParameters.click_function = \"expertClick\"\n args.object.createButton(buttonParameters)\n buttonParameters.position[3] = buttonParameters.position[3] + 0.20\n end\n\n if data.standalone ~= nil then\n buttonParameters.label = \"Standalone\"\n buttonParameters.click_function = \"standaloneClick\"\n args.object.createButton(buttonParameters)\n end\n end\nend\n\n-- called for adding chaos tokens\n---@param args table Parameters for this function:\n-- object object Usually \"self\"\n-- key string Name of the scenario\n-- mode string difficulty (e.g. \"hard\" or \"expert\")\nfunction fillContainer(args)\n local data = getDataValue('modeData', args.key)\n if data == nil then return end\n\n local value = data[args.mode]\n if value == nil or value.token == nil then return end\n\n local tokenList = {}\n\n for _, tokenId in ipairs(value.token) do\n table.insert(tokenList, tokenId)\n end\n\n if value.append ~= nil then\n for _, tokenId in ipairs(value.append) do\n table.insert(tokenList, tokenId)\n end\n end\n\n -- randomly choose tokens for specific Carcosa scenarios in standalone\n if value.random then\n local n = #value.random\n if n \u003e 0 then\n for _, tokenId in ipairs(value.random[math.random(1, n)]) do\n table.insert(tokenList, tokenId)\n end\n end\n end\n\n setChaosBagState(tokenList)\n\n if value.message then\n broadcastToAll(value.message)\n end\n\n if value.warning then\n broadcastToAll(value.warning, { 1, 0.5, 0.5 })\n end\nend\n\nfunction getDataValue(storage, key)\n local DATA_HELPER = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n local data = DATA_HELPER.getTable(storage)\n if data ~= nil then\n local value = data[key]\n if value ~= nil then\n local res = {}\n for m, v in pairs(value) do\n res[m] = v\n if res[m].parent ~= nil then\n local parentData = getDataValue(storage, res[m].parent)\n if parentData ~= nil and parentData[m] ~= nil and parentData[m].token ~= nil then\n res[m].token = parentData[m].token\n end\n res[m].parent = nil\n end\n end\n return res\n end\n end\nend\n\nfunction createChaosTokenNameLookupTable()\n local namesToIds = {}\n for k, v in pairs(ID_URL_MAP) do\n namesToIds[v.name] = k\n end\n return namesToIds\nend\n\n-- returns the currently drawn chaos tokens\n---@api ChaosBagApi\nfunction getChaosTokensinPlay()\n return chaosTokens\nend\n\n-- returns a Table List of chaos token ids in the current chaos bag\n---@api ChaosBag / ChaosBagApi\nfunction getChaosBagState()\n local tokens = {}\n local invertedTable = createChaosTokenNameLookupTable()\n local chaosBag = findChaosBag()\n\n for _, v in ipairs(chaosBag.getObjects()) do\n local id = invertedTable[v.name]\n if id then\n table.insert(tokens, id)\n else\n printToAll(v.name .. \" token not recognized. Will not be recorded.\", \"Yellow\")\n end\n end\n\n return tokens\nend\n\n-- respawns the chaos bag with a new state of tokens\n---@param tokenList table List of chaos token ids\n---@api ChaosBag / ChaosBagApi\nfunction setChaosBagState(tokenList)\n if not canTouchChaosTokens() then return end\n\n local chaosBag = findChaosBag()\n local chaosBagData = chaosBag.getData()\n local reserveData = getObjectFromGUID(\"106418\").getData()\n local tokenCache = {}\n local containedObjects = {}\n\n -- create a temporary copy of the data for each chaos token\n for _, objData in ipairs(reserveData.ContainedObjects) do\n tokenCache[objData.Nickname] = objData\n end\n\n -- iterate over tokenlist and insert specified tokens into new table\n for _, tokenId in ipairs(tokenList) do\n local tokenName = ID_URL_MAP[tokenId].name\n table.insert(containedObjects, tokenCache[tokenName])\n end\n\n -- overwrite chaos bag content and respawn it\n chaosBagData.ContainedObjects = containedObjects\n chaosBag.destruct()\n spawnObjectData({ data = chaosBagData })\n\n -- remove tokens that are still in play\n for _, token in pairs(chaosTokens) do\n if token ~= nil then token.destruct() end\n end\n chaosTokens = {}\n chaosTokensLastMatGUID = nil\n\n -- reset bless / curse manager\n blessCurseManagerApi.removeTakenTokensAndReset()\n\n printToAll(\"Chaos Bag set to chosen difficulty.\", \"Green\")\nend\n\n-- spawns the specified chaos token and puts it into the chaos bag\n---@param id string ID of the chaos token\nfunction spawnChaosToken(id)\n if not canTouchChaosTokens() then return end\n\n id = id:lower()\n local chaosBag = findChaosBag()\n local url = ID_URL_MAP[id].url or \"\"\n\n if url ~= \"\" then\n return spawnObject({\n type = 'Custom_Tile',\n position = { 0.49, 3, 0 },\n scale = { 0.81, 1.0, 0.81 },\n rotation = { 0, 270, 0 },\n callback_function = function(obj)\n obj.setName(ID_URL_MAP[id].name)\n chaosBag.putObject(obj)\n tokenArrangerApi.layout()\n end\n }).setCustomObject({\n type = 2,\n image = url,\n thickness = 0.1\n })\n end\nend\n\n-- removes the specified chaos token from the chaos bag\n---@param id string ID of the chaos token\nfunction removeChaosToken(id)\n if not canTouchChaosTokens() then return end\n\n local tokens = {}\n local chaosBag = findChaosBag()\n local name = ID_URL_MAP[id].name\n\n for _, v in ipairs(chaosBag.getObjects()) do\n if v.name == name then table.insert(tokens, v.guid) end\n end\n\n -- error handling: no matching token found\n if #tokens == 0 then\n printToAll(\"No \" .. name .. \" tokens in the chaos bag.\", \"Yellow\")\n return\n end\n\n chaosBag.takeObject({\n guid = tokens[1],\n smooth = false,\n callback_function = function(obj)\n obj.destruct()\n tokenArrangerApi.layout()\n end\n })\n printToAll(\"Removing \" .. name .. \" token (in bag: \" .. #tokens - 1 .. \")\", \"White\")\nend\n\n-- empty the chaos bag\nfunction emptyChaosBag()\n if not canTouchChaosTokens() then return end\n\n local chaosBag = findChaosBag()\n for _, object in ipairs(chaosBag.getObjects()) do\n chaosBag.takeObject({ callback_function = function(item) item.destruct() end })\n end\nend\n\n-- returns all sealed tokens on cards to the chaos bag\nfunction releaseAllSealedTokens(playerColor)\n local chaosBag = findChaosBag()\n for _, obj in ipairs(getObjectsWithTag(\"CardThatSeals\")) do\n obj.call(\"releaseAllTokens\", playerColor)\n end\nend\n\n---------------------------------------------------------\n-- Content Importing and XML functions\n---------------------------------------------------------\n\n-- forwards the requested content type to the update function and sets highlight to clicked tab\n---@param tabId string Id of the clicked tab\nfunction onClick_tab(_, _, tabId)\n for listId, listContent in pairs(tabIdTable) do\n if listId == tabId then\n UI.setClass(listId, 'downloadTab activeTab')\n contentToShow = listContent\n else\n UI.setClass(listId, 'downloadTab')\n end\n end\n currentListItem = 1\n updateDownloadItemList()\nend\n\n-- click function for the items in the download window\n-- updates backgroundcolor for row panel and fontcolor for list item\nfunction onClick_select(_, _, identificationKey)\n UI.setAttribute(\"panel\" .. currentListItem, \"color\", \"clear\")\n UI.setAttribute(contentToShow .. \"_\" .. currentListItem, \"color\", \"white\")\n \n -- parses the identification key (contentToShow_currentListItem)\n if identificationKey then\n contentToShow = nil\n currentListItem = nil\n for str in string.gmatch(identificationKey, \"([^_]+)\") do\n if not contentToShow then\n -- grab the first part to know the content type\n contentToShow = str\n else\n -- get the index\n currentListItem = tonumber(str)\n break\n end\n end\n end\n\n UI.setAttribute(\"panel\" .. currentListItem, \"color\", \"grey\")\n UI.setAttribute(contentToShow .. \"_\" .. currentListItem, \"color\", \"black\")\n updatePreviewWindow()\nend\n\n-- click function for the \"Custom URL\" button in the playarea image gallery\nfunction onClick_customUrl(player)\n changeWindowVisibilityForColor(player.color, \"playareaGallery\")\n Wait.time(function()\n player.showInputDialog(\"Enter a custom URL for the playarea image\", \"\", function(newURL)\n playAreaApi.updateSurface(newURL)\n end)\n end, 0.15)\nend\n\n-- click function for the download button in the preview window\nfunction onClick_download(player)\n local params = library[contentToShow][currentListItem]\n params.player = player\n placeholder_download(params)\nend\n\n-- the download button on the placeholder objects calls this to directly initiate a download\n---@param params table contains url and guid of replacement object\nfunction placeholder_download(params)\n function downloadCoroutine()\n -- show progress bar\n UI.setAttribute('download_progress', 'active', true)\n\n -- update progress bar\n while requestObj do\n UI.setAttribute('download_progress', 'percentage', requestObj.download_progress * 100)\n coroutine.yield(0)\n end\n UI.setAttribute('download_progress', 'percentage', 100)\n\n -- wait 30 frames\n for i = 1, 30 do\n coroutine.yield(0)\n end\n\n -- hide progress bar\n UI.setAttribute('download_progress', 'active', false)\n\n -- hide download window\n changeWindowVisibilityForColor(params.player.color, \"downloadWindow\", false)\n return 1\n end\n\n local url = SOURCE_REPO .. '/' .. params.url\n requestObj = WebRequest.get(url, function (request) contentDownloadCallback(request, params) end)\n startLuaCoroutine(Global, 'downloadCoroutine')\nend\n\n-- spawns a bag that contains every object from the library\nfunction onClick_downloadAll(player)\n broadcastToAll(\"Download initiated - this will take a few minutes!\")\n\n -- hide download window\n changeWindowVisibilityForColor(player.color, \"downloadWindow\", false)\n\n startLuaCoroutine(Global, \"coroutineDownloadAll\")\nend\n\nfunction coroutineDownloadAll()\n local JSON = [[\n {\n \"Name\": \"Bag\",\n \"Transform\": {\n \"posX\": {{POSX}},\n \"posY\": 2,\n \"posZ\": -95,\n \"rotX\": 0,\n \"rotY\": 270,\n \"rotZ\": 0,\n \"scaleX\": 1,\n \"scaleY\": 1,\n \"scaleZ\": 1\n },\n \"Nickname\": \"{{NICKNAME}}\",\n \"Bag\": {\n \"Order\": 0\n },\n \"ContainedObjects\": [\n ]]\n\n local posx = -45.0\n local downloadedItems = 0\n local skippedItems = 0\n\n -- loop through the library to add content\n for contentType, objectList in pairs(library) do\n broadcastToAll(\"Downloading \" .. contentType .. \"...\")\n local contained = \"\"\n for _, params in ipairs(objectList) do\n local request = WebRequest.get(SOURCE_REPO .. '/' .. params.url, function() end)\n local start = os.time()\n while true do\n if request.is_done then\n contained = contained .. request.text .. \",\"\n downloadedItems = downloadedItems + 1\n break\n -- time-out if item can't be loaded in 5s\n elseif request.is_error or (os.time() - start) \u003e 5 then\n skippedItems = skippedItems + 1\n break\n end\n coroutine.yield(0)\n end\n end\n local JSONCopy = JSON\n JSONCopy = JSONCopy .. contained .. \"]}\"\n JSONCopy = JSONCopy:gsub(\"{{POSX}}\", posx)\n JSONCopy = JSONCopy:gsub(\"{{NICKNAME}}\", contentType)\n spawnObjectJSON({json = JSONCopy})\n posx = posx + 3\n end\n\n broadcastToAll(downloadedItems .. \" objects downloaded.\", \"Green\")\n broadcastToAll(skippedItems .. \" objects had a time-out / error.\", \"Orange\")\n return 1\nend\n\n-- spawns a placeholder box for the selected object\nfunction onClick_spawnPlaceholder(player)\n -- get object references\n local item = library[contentToShow][currentListItem]\n local dummy = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlaceholderBoxDummy\")\n\n -- error handling\n if not item.boxsize or item.boxsize == \"\" or not item.boxart or item.boxart == \"\" then\n print(\"Error loading object.\")\n return\n end\n\n -- get data for placeholder\n local spawnPos = {-39.5, 2, -87}\n\n local meshTable = {\n big = \"https://raw.githubusercontent.com/RobMayer/TTSLibrary/master/advboxes/core_h_MSH.obj\",\n small = \"https://raw.githubusercontent.com/RobMayer/TTSLibrary/master/advboxes/tuckbox_h_MSH.obj\",\n wide = \"http://cloud-3.steamusercontent.com/ugc/2278324073260846176/33EFCAF30567F8756F665BE5A2A6502E9C61C7F7/\"\n }\n\n local scaleTable = {\n big = {1.00, 0.14, 1.00},\n small = {2.21, 0.46, 2.42},\n wide = {2.00, 0.11, 1.69}\n }\n\n local placeholder = spawnObject({\n type = \"Custom_Model\",\n position = spawnPos,\n rotation = {0, 270, 0},\n scale = scaleTable[item.boxsize],\n })\n\n placeholder.setCustomObject({\n mesh = meshTable[item.boxsize],\n diffuse = item.boxart,\n material = 3\n })\n\n if item.boxsize == \"big\" then\n placeholder.addTag(\"LargeBox\")\n end\n\n placeholder.setColorTint({1, 1, 1, 71/255})\n placeholder.setName(item.name)\n placeholder.setDescription(\"by \" .. (item.author or \"Unknown\"))\n placeholder.setGMNotes(item.url)\n placeholder.setLuaScript(dummy.getLuaScript())\n Player.getPlayers()[1].pingTable(spawnPos)\n\n -- hide download window\n changeWindowVisibilityForColor(player.color, \"downloadWindow\", false)\nend\n\n-- toggles the visibility of the respective UI\n---@param player tts__Player Player that triggered this\n---@param windowId string Name of the UI to toggle\nfunction onClick_toggleUi(player, windowId)\n if windowId == \"Navigation Overlay\" then\n navigationOverlayApi.cycleVisibility(player.color)\n return\n end\n\n -- hide the playAreaGallery if visible\n if windowId == \"downloadWindow\" then\n changeWindowVisibilityForColor(player.color, \"playAreaGallery\", false)\n -- hide the downloadWindow if visible\n elseif windowId == \"playAreaGallery\" then\n changeWindowVisibilityForColor(player.color, \"downloadWindow\", false)\n end\n\n changeWindowVisibilityForColor(player.color, windowId)\nend\n\n-- toggles the visibility of the specific window for the specified color\n---@param color string Player color to toggle the visibility for\n---@param windowId string ID of the XML element\n---@param overrideState? boolean Forcefully sets the new visibility\n---@return boolean visible Returns the new state of the visibility\nfunction changeWindowVisibilityForColor(color, windowId, overrideState)\n -- current state\n local colorString = UI.getAttribute(windowId, \"visibility\") or \"\"\n\n -- parse the visibility string\n local visible = false\n local viewers = {}\n for str in string.gmatch(colorString, \"%a+\") do\n table.insert(viewers, str)\n if str == color then\n visible = true\n end\n end\n\n -- add / remove the color as viewer\n if visible == true then\n removeValueFromTable(viewers, color)\n elseif visible == false then\n table.insert(viewers, color)\n end\n visible = not visible\n\n -- resolve override\n if overrideState == true and visible == false then\n table.insert(viewers, color)\n visible = true\n elseif overrideState == false and visible == true then\n removeValueFromTable(viewers, color)\n visible = false\n end\n\n -- construct new string\n local newColorString = \"\"\n for _, viewer in ipairs(viewers) do\n newColorString = newColorString .. viewer .. \"|\"\n end\n\n -- remove last delimiter\n newColorString = newColorString:sub(1, -2)\n\n -- update the visibility of the XML\n UI.setAttribute(windowId, \"visibility\", newColorString)\n UI.setAttribute(windowId, \"active\", newColorString ~= \"\")\n\n return visible\nend\n\n-- forwards the call to the onClick function\nfunction togglePlayAreaGallery(playerColor)\n changeWindowVisibilityForColor(playerColor, \"playareaGallery\")\nend\n\n-- updates the preview window\nfunction updatePreviewWindow()\n local item = library[contentToShow][currentListItem]\n local tempImage = \"http://cloud-3.steamusercontent.com/ugc/2115061845788345842/2CD6ABC551555CCF58F9D0DDB7620197BA398B06/\"\n\n -- set default image if not defined\n if item.boxsize == nil or item.boxsize == \"\" or item.boxart == nil or item.boxart == \"\" then\n item.boxsize = \"big\"\n item.boxart = \"http://cloud-3.steamusercontent.com/ugc/762723517667628371/18438B0A0045038A7099648AA3346DFCAA267C66/\"\n end\n\n UI.setValue(\"previewTitle\", item.name)\n UI.setValue(\"previewAuthor\", \"by \" .. (item.author or \"- Author not found -\"))\n UI.setValue(\"previewDescription\", item.description or \"- Description not found -\")\n\n -- update mask according to size (hardcoded values to align image in mask)\n local maskData = {}\n if item.boxsize == \"big\" then\n maskData = {\n image = \"box-cover-mask-big\",\n width = \"870\",\n height = \"435\",\n offsetXY = \"154 60\"\n }\n elseif item.boxsize == \"small\" then\n maskData = {\n image = \"box-cover-mask-small\",\n width = \"792\",\n height = \"594\",\n offsetXY = \"135 13\"\n }\n elseif item.boxsize == \"wide\" then\n maskData = {\n image = \"box-cover-mask-wide\",\n width = \"756\",\n height = \"630\",\n offsetXY = \"-190 -70\"\n }\n end\n\n -- loading empty image as placeholder until real image is loaded\n UI.setAttribute(\"previewArtImage\", \"image\", tempImage)\n \n -- insert the image itself\n UI.setAttribute(\"previewArtImage\", \"image\", item.boxart)\n UI.setAttributes(\"previewArtMask\", maskData)\nend\n\n-- formats the json response from the webrequest into a key-value lua table\n-- strips the prefix from the community content items\nfunction formatLibrary(json_response)\n library = {}\n library[\"campaigns\"] = json_response.campaigns\n library[\"scenarios\"] = json_response.scenarios\n library[\"extras\"] = json_response.extras\n library[\"fanmadeCampaigns\"] = {}\n library[\"fanmadeScenarios\"] = {}\n library[\"fanmadePlayerCards\"] = {}\n\n for _, item in ipairs(json_response.community) do\n local identifier = nil\n for str in string.gmatch(item.name, \"([^:]+)\") do\n if not identifier then\n -- grab the first part to know the content type\n identifier = str\n else\n -- update the name without the content type\n item.name = str\n break\n end\n end\n\n if identifier == \"Fan Investigators\" then\n table.insert(library[\"fanmadePlayerCards\"], item)\n elseif identifier == \"Fan Campaign\" then\n table.insert(library[\"fanmadeCampaigns\"], item)\n elseif identifier == \"Fan Scenario\" then\n table.insert(library[\"fanmadeScenarios\"], item)\n end\n end\nend\n\n-- updates the window content to the requested content\nfunction updateDownloadItemList()\n if not library then return end\n\n -- addition of list items according to library file\n local globalXml = UI.getXmlTable()\n local contentList = getXmlTableElementById(globalXml, 'contentList')\n\n contentList.children = {}\n for i, v in ipairs(library[contentToShow]) do\n table.insert(contentList.children,\n {\n tag = \"Panel\",\n attributes = { id = \"panel\" .. i },\n children = {\n tag = 'Text',\n value = v.name,\n attributes = {\n id = contentToShow .. \"_\" .. i,\n onClick = 'onClick_select',\n alignment = 'MiddleLeft'\n }\n }\n })\n end\n\n contentList.attributes.height = #contentList.children * 27\n updateGlobalXml(globalXml)\n\n -- select the first item\n Wait.time(onClick_select, 0.2)\nend\n\n-- this helper function updates the global XML while preserving the visibility of windows\nfunction updateGlobalXml(newXml)\n -- preserve visibility settings for these elements\n local windowIdList = {\n \"playAreaGallery\",\n \"downloadWindow\",\n \"optionPanel\"\n }\n\n -- get current state and update newXml\n for _, windowId in ipairs(windowIdList) do\n local element = getXmlTableElementById(newXml, windowId)\n element.attributes.active = UI.getAttribute(windowId, \"active\")\n element.attributes.visibility = UI.getAttribute(windowId, \"visibility\")\n end\n\n UI.setXmlTable(newXml)\nend\n\n-- called after the webrequest of downloading an item\n-- deletes the placeholder and spawns the downloaded item\nfunction contentDownloadCallback(request, params)\n requestObj = nil\n\n -- error handling\n if request.is_error or request.response_code ~= 200 then\n print('Error: ' .. request.error)\n return\n end\n\n -- initiate content spawning\n local spawnTable = { json = request.text }\n if params.replace then\n local replacedObject = getObjectFromGUID(params.replace)\n if replacedObject then\n spawnTable.position = replacedObject.getPosition()\n spawnTable.rotation = replacedObject.getRotation()\n spawnTable.scale = replacedObject.getScale()\n destroyObject(replacedObject)\n end\n end\n\n -- if position is undefined, get empty position\n if not spawnTable.position then\n spawnTable.rotation = { 0, 270, 0}\n\n local pos = getValidSpawnPosition()\n if pos then\n spawnTable.position = pos\n else\n broadcastToAll(\"Please make space in the area below the tentacle stand in the upper middle of the table and try again.\", \"Red\")\n return\n end\n end\n\n -- if spawned from menu, move the camera and/or ping the table\n if params.name then\n spawnTable[\"callback_function\"] = function(obj)\n Wait.time(function()\n -- move camera\n if params.player then\n params.player.lookAt({\n position = obj.getPosition(),\n pitch = 65,\n yaw = 90,\n distance = 65\n })\n end\n \n -- ping object\n local pingPlayer = params.player or Player.getPlayers()[1]\n pingPlayer.pingTable(obj.getPosition())\n end, 0.1)\n end\n end\n\n if pcall(function() spawnObjectJSON(spawnTable) end) then\n print('Object loaded.')\n else\n print('Error loading object.')\n end\nend\n\n-- gets the first empty position to spawn a custom content object safely\nfunction getValidSpawnPosition()\n local potentialSpawnPositionX = { 65, 50, 35 }\n local potentialSpawnPositionY = 1.5\n local potentialSpawnPositionZ = { 35, 21, 7, -7, -21, -35 }\n\n for i, posX in ipairs(potentialSpawnPositionX) do\n for j, posZ in ipairs(potentialSpawnPositionZ) do\n local pos = {\n x = posX,\n y = potentialSpawnPositionY,\n z = posZ,\n }\n if checkPositionForContentSpawn(pos) then\n return pos\n end\n end\n end\n return nil\nend\n\n-- checks whether something is in the specified position\n-- returns true if empty\nfunction checkPositionForContentSpawn(checkPos)\n local searchResult = searchLib.atPosition(checkPos)\n\n -- first hit is the table surface, additional hits means something is there\n return #searchResult == 1\nend\n\n-- downloading of the library file\nfunction libraryDownloadCallback(request)\n if request.is_error or request.response_code ~= 200 then\n print('error: ' .. request.error)\n return\n end\n\n local json_response = nil\n if pcall(function () json_response = JSON.decode(request.text) end) then\n formatLibrary(json_response)\n updateDownloadItemList()\n else\n print('error parsing downloaded library')\n end\nend\n\n-- loops through an XML table and returns the specified object\n---@param ui table XmlTable (get this via getXmlTable)\n---@param id string Id of the object to return\nfunction getXmlTableElementById(ui, id)\n for _, obj in ipairs(ui) do\n if obj.attributes and obj.attributes.id and obj.attributes.id == id then return obj end\n if obj.children then\n local result = getXmlTableElementById(obj.children, id)\n if result then return result end\n end\n end\n return nil\nend\n\n---------------------------------------------------------\n-- Option Panel related functionality\n---------------------------------------------------------\n\n-- called by toggling an option\nfunction onClick_toggleOption(_, id)\n local state = self.UI.getAttribute(id, \"isOn\")\n\n -- flip state (and handle stupid \"False\" value)\n if state == \"False\" then\n state = true\n else\n state = false\n end\n\n self.UI.setAttribute(id, \"isOn\", state)\n applyOptionPanelChange(id, state)\nend\n\n-- color selection for playArea\nfunction onClick_playAreaConnectionColor(player, _, id)\n player.showColorDialog(optionPanel[id], function(color)\n applyOptionPanelChange(id, color)\n end)\nend\n\n-- called by the language selection dropdown\nfunction languageSelected(_, selectedIndex, id)\n optionPanel[id] = LANGUAGES[tonumber(selectedIndex) + 1].code\nend\n\n-- returns the ID (position in the table) for a provided language code\nfunction returnLanguageId(code)\n for index, tbl in ipairs(LANGUAGES) do\n if tbl.code == code then\n return index\n end\n end\nend\n\n-- called by the resource counter selection dropdown\nfunction resourceCounterSelected(_, selectedIndex, id)\n optionPanel[id] = RESOURCE_OPTIONS[tonumber(selectedIndex) + 1]\nend\n\n-- returns the ID for the provided option name\nfunction returnResourceCounterId(name)\n for index, optionName in ipairs(RESOURCE_OPTIONS) do\n if optionName == name then\n return index\n end\n end\nend\n\n-- called by the playermat removal selection dropdown\nfunction playermatRemovalSelected(player, selectedIndex, id)\n if selectedIndex == \"0\" then return end\n\n local matColorList = { \"White\", \"Orange\", \"Green\", \"Red\" }\n local matColor = matColorList[tonumber(selectedIndex)]\n local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\")\n\n if mat then\n -- confirmation dialog about deletion\n player.pingTable(mat.getPosition())\n player.showConfirmDialog(\"Do you really want to remove \" .. matColor .. \"'s playermat and related objects? This can't be reversed.\", function() removePlayermat(matColor) end)\n else\n -- info dialog that it is already deleted\n player.showInfoDialog(matColor .. \"'s playermat has already been removed.\")\n end\n\n -- set selected value back to first option\n UI.setAttribute(id, \"value\", 0)\nend\n\n-- removes a playermat and all related objects from play\n---@param matColor string Color of the playermat to remove\nfunction removePlayermat(matColor)\n local matObjects = guidReferenceApi.getObjectsByOwner(matColor)\n if not matObjects.Playermat then return end\n\n -- remove action tokens\n local actionTokens = playmatApi.searchAroundPlaymat(matColor, \"isActionToken\")\n for _, obj in ipairs(actionTokens) do\n obj.destruct()\n end\n\n -- remove mat owned objects\n for _, obj in pairs(matObjects) do\n obj.destruct()\n end\nend\n\n-- sets the option panel to the correct state (corresponding to 'optionPanel')\nfunction updateOptionPanelState()\n for id, optionValue in pairs(optionPanel) do\n if id == \"cardLanguage\" and type(optionValue) == \"string\" then\n local dropdownId = returnLanguageId(optionValue) - 1\n UI.setAttribute(id, \"value\", dropdownId)\n elseif id == \"useResourceCounters\" and type(optionValue) == \"string\" then\n local dropdownId = returnResourceCounterId(optionValue) - 1\n UI.setAttribute(id, \"value\", dropdownId)\n elseif id == \"playAreaConnectionColor\" then\n UI.setAttribute(id, \"color\", \"#\" .. Color.new(optionValue):toHex())\n elseif (type(optionValue) == \"boolean\" and optionValue)\n or (type(optionValue) == \"string\" and optionValue)\n or (type(optionValue) == \"table\" and #optionValue ~= 0) then\n UI.setAttribute(id, \"isOn\", true)\n else\n UI.setAttribute(id, \"isOn\", \"False\")\n end\n end\nend\n\n-- handles the applying of option selections and calls the respective functions based\n---@param id string ID of the option that was selected or deselected\n---@param state boolean|any State of the option (true = enabled)\nfunction applyOptionPanelChange(id, state)\n -- option: Snap tags\n if id == \"useSnapTags\" then\n playmatApi.setLimitSnapsByType(state, \"All\")\n optionPanel[id] = state\n\n -- option: Draw 1 button\n elseif id == \"showDrawButton\" then\n playmatApi.showDrawButton(state, \"All\")\n optionPanel[id] = state\n\n -- option: Clickable clue counters\n elseif id == \"useClueClickers\" then\n playmatApi.clickableClues(state, \"All\")\n optionPanel[id] = state\n\n -- update master clue counter\n local counter = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MasterClueCounter\")\n counter.setVar(\"useClickableCounters\", state)\n\n -- option: Play area snap tags\n elseif id == \"playAreaConnections\" then\n playAreaApi.setConnectionDrawState(state)\n optionPanel[id] = state\n\n -- option: Play area connection color\n elseif id == \"playAreaConnectionColor\" then\n playAreaApi.setConnectionColor(state)\n UI.setAttribute(id, \"color\", \"#\" .. Color.new(state):toHex())\n optionPanel[id] = state\n\n -- option: Play area snap tags\n elseif id == \"playAreaSnapTags\" then\n playAreaApi.setLimitSnapsByType(state)\n optionPanel[id] = state\n\n -- option: Show Title on placing scenarios\n elseif id == \"showTitleSplash\" then\n optionPanel[id] = state\n\n -- option: Change custom playarea image on setup\n elseif id == \"changePlayAreaImage\" then\n optionPanel[id] = state\n\n -- option: Show clean up helper\n elseif id == \"showCleanUpHelper\" then\n optionPanel[id] = spawnOrRemoveHelper(state, \"Clean Up Helper\", {-66, 1.6, 46})\n\n -- option: Show hand helper for each player\n elseif id == \"showHandHelper\" then\n spawnOrRemoveHelperForPlayermats(\"Hand Helper\", state)\n optionPanel[id] = state\n\n -- option: Show search assistant for each player\n elseif id == \"showSearchAssistant\" then\n spawnOrRemoveHelperForPlayermats(\"Search Assistant\", state)\n optionPanel[id] = state\n\n -- option: Show attachment helper\n elseif id == \"showAttachmentHelper\" then\n optionPanel[id] = spawnOrRemoveHelper(state, \"Attachment Helper\", {-62, 1.4, 0})\n\n -- option: Show CYOA campaign guides\n elseif id == \"showCYOA\" then\n optionPanel[id] = spawnOrRemoveHelper(state, \"CYOA Campaign Guides\", { 39, 1.3, -20})\n\n -- option: Show displacement tool\n elseif id == \"showDisplacementTool\" then\n optionPanel[id] = spawnOrRemoveHelper(state, \"Displacement Tool\", {-57, 1.6, 46})\n end\nend\n\n-- spawns or removes a helper object for all playermats\n---@param helperName string Name of the helper object\n---@param state boolean Contains the state of the option: true = spawn it, false = remove it\nfunction spawnOrRemoveHelperForPlayermats(helperName, state)\n for color, data in pairs(playmatApi.getHelperSpawnData(\"All\", helperName)) do\n spawnOrRemoveHelper(state, helperName, data.position, data.rotation, color)\n end\nend\n\n-- handler for spawn / remove functions of helper objects\n---@param state boolean Contains the state of the option: true = spawn it, false = remove it\n---@param name string Name of the helper object\n---@param position tts__Vector Position of the object (where it will spawn)\n---@param rotation? tts__Vector Rotation of the object for spawning (default: {0, 270, 0})\n---@param owner? string Owner of the object (defaults to \"Mythos\")\n---@return string|nil GUID GUID of the spawnedObj (or nil if object was removed)\nfunction spawnOrRemoveHelper(state, name, position, rotation, owner)\n if state then\n Player.getPlayers()[1].pingTable(position)\n local spawnedGUID = spawnHelperObject(name, position, rotation).getGUID()\n local cleanName = name:gsub(\"%s+\", \"\")\n guidReferenceApi.editIndex(owner or \"Mythos\", cleanName, spawnedGUID)\n else\n return removeHelperObject(name)\n end\nend\n\n-- copies the specified tool (by name) from the option panel source bag\n---@param name string Name of the object that should be copied\n---@param position tts__Vector Desired position of the object\n---@param rotation? tts__Vector Desired rotation of the object (defaults to object's rotation)\nfunction spawnHelperObject(name, position, rotation)\n local sourceBag = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"OptionPanelSource\")\n\n -- error handling for missing sourceBag\n if not sourceBag then\n broadcastToAll(\"Option panel source bag could not be found!\", \"Red\")\n return\n end\n\n local spawnTable = { position = position }\n\n -- only overrride rotation if there is one provided (object's rotation used instead)\n if rotation then\n spawnTable.rotation = rotation\n end\n\n for _, obj in ipairs(sourceBag.getData().ContainedObjects) do\n if obj[\"Nickname\"] == name then\n spawnTable.data = obj\n spawnTable.callback_function = function(spawnedObj)\n Wait.time(function() spawnedObj.setLock(true) end, 2)\n end\n return spawnObjectData(spawnTable)\n end\n end\nend\n\n-- removes the specified tool (by name)\n---@param name string Object that should be removed\nfunction removeHelperObject(name)\n local cleanName = name:gsub(\"%s+\", \"\")\n for _, obj in pairs(guidReferenceApi.getObjectsByType(cleanName)) do\n obj.destruct()\n end\nend\n\n-- loads saved options\n---@param newOptions table Contains the new state for the option panel\nfunction loadSettings(newOptions)\n for id, state in pairs(newOptions) do\n if optionPanel[id] ~= state then\n optionPanel[id] = state\n applyOptionPanelChange(id, state)\n end\n end\n\n -- update XML UI state\n updateOptionPanelState()\nend\n\n-- loads the default options\nfunction onClick_defaultSettings()\n for id, _ in pairs(optionPanel) do\n local state = false\n -- override for settings that are enabled by default\n if id == \"useSnapTags\" or id == \"showTitleSplash\" then\n state = true\n end\n applyOptionPanelChange(id, state)\n end\n\n -- clean reset of variables\n optionPanel = {\n cardLanguage = \"en\",\n changePlayAreaImage = false,\n playAreaConnectionColor = { a = 1, b = 0.4, g = 0.4, r = 0.4 },\n playAreaConnections = true,\n playAreaSnapTags = true,\n showAttachmentHelper = false,\n showCleanUpHelper = false,\n showCYOA = false,\n showDisplacementTool = false,\n showDrawButton = false,\n showHandHelper = false,\n showSearchAssistant = false,\n showTitleSplash = true,\n useClueClickers = false,\n useResourceCounters = \"disabled\",\n useSnapTags = true\n }\n\n -- update UI\n updateOptionPanelState()\nend\n\n-- splash scenario title on setup\nfunction titleSplash(scenarioName)\n if optionPanel['showTitleSplash'] then\n -- if there's any ongoing title being displayed, hide it and cancel the waiting function\n if hideTitleSplashWaitFunctionId then\n Wait.stop(hideTitleSplashWaitFunctionId)\n hideTitleSplashWaitFunctionId = nil\n UI.setAttribute('title_splash', 'active', false)\n end\n\n -- display scenario name and set a 4 seconds (2 seconds animation and 2 seconds on screen)\n -- wait timer to hide the scenario name\n UI.setValue('title_splash_text', scenarioName)\n UI.show('title_splash')\n hideTitleSplashWaitFunctionId = Wait.time(function()\n UI.hide('title_splash')\n hideTitleSplashWaitFunctionId = nil\n end, 4)\n\n soundCubeApi.playSoundByName(\"Deep Bell\")\n end\nend\n\n---------------------------------------------------------\n-- Update notification related functionality\n---------------------------------------------------------\n\n-- grabs the latest mod version and release notes from GitHub (called onLoad())\nfunction getModVersion()\n WebRequest.get(SOURCE_REPO .. '/modversion.json', compareVersion)\nend\n\n-- compares the modversion with GitHub and possibly shows the update notification\nfunction compareVersion(request)\n if request.is_error then\n log(request.error)\n return\n end\n\n -- global variable to make it accessible for other functions\n modMeta = JSON.decode(request.text)\n\n -- stop here if on latest or newer version\n if convertVersionToNumber(MOD_VERSION) \u003e= convertVersionToNumber(modMeta[\"latestVersion\"]) then return end\n\n -- stop here if \"don't show again\" was clicked for this version before\n if acknowledgedUpgradeVersions[modMeta[\"latestVersion\"]] then return end\n\n updateNotificationLoading()\n\n -- delay to avoid lagging during onLoad()\n Wait.time(function() UI.show(\"FinnIcon\") end, 1)\nend\n\n-- converts a version number to a string\n---@param version string Version number, separated by dots (e.g. 3.3.1)\nfunction convertVersionToNumber(version)\n local major, minor, patch = string.match(version, \"(%d+)%.(%d+)%.(%d+)\")\n return major * 100 + minor * 10 + patch\nend\n\n-- updates the XML update notification based on the mod metadata\nfunction updateNotificationLoading()\n -- grab data\n local highlights = modMeta[\"releaseHighlights\"]\n\n -- concatenate the release highlights\n local highlightText = \"• \" .. highlights[1]\n for i, entry in pairs(highlights) do\n if i ~= 1 then\n highlightText = highlightText .. \"\\n• \" .. entry\n end\n end\n\n -- update the XML UI\n UI.setValue(\"notificationHeader\", \"New version available: \" .. modMeta[\"latestVersion\"])\n UI.setValue(\"releaseHighlightText\", highlightText)\n UI.setAttribute(\"highlightRow\", \"preferredHeight\", 20*#highlights)\n UI.setAttribute(\"updateNotification\", \"height\", 20*#highlights + 125)\nend\n\n-- close / don't show again buttons on the update notification\nfunction onClick_notification(_, parameter)\n if parameter == \"dontShowAgain\" then\n -- this variable tracks if \"don't show again\" was pressed for a version\n acknowledgedUpgradeVersions[modMeta[\"latestVersion\"]] = true\n end\n UI.hide(\"FinnIcon\")\n UI.hide(\"updateNotification\")\nend\n\n---------------------------------------------------------\n-- Utility functions\n---------------------------------------------------------\n\nfunction removeValueFromTable(t, val)\n for i, v in ipairs(t) do\n if v == val then\n table.remove(t, i)\n break\n end\n end\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat\n ---@param mat tts__Object Playermat that triggered this\n ---@param alwaysFaceUp boolean Whether the card should be drawn face-up\n MythosAreaApi.drawEncounterCard = function(mat, alwaysFaceUp)\n getMythosArea().call(\"drawEncounterCard\", {mat = mat, alwaysFaceUp = alwaysFaceUp})\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"core/NavigationOverlayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local NavigationOverlayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getNOHandler()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"NavigationOverlayHandler\")\n end\n\n -- copies the visibility for the Navigation overlay\n ---@param startColor string Color of the player to copy from\n ---@param targetColor string Color of the targeted player\n NavigationOverlayApi.copyVisibility = function(startColor, targetColor)\n getNOHandler().call(\"copyVisibility\", {\n startColor = startColor,\n targetColor = targetColor\n })\n end\n\n -- changes the Navigation Overlay view (\"Full View\" --\u003e \"Play Areas\" --\u003e \"Closed\" etc.)\n ---@param playerColor string Color of the player to update the visibility for\n NavigationOverlayApi.cycleVisibility = function(playerColor)\n getNOHandler().call(\"cycleVisibility\", playerColor)\n end\n\n -- loads the specified camera for a player\n ---@param player tts__Player Player whose camera should be moved\n ---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to\n NavigationOverlayApi.loadCamera = function(player, camera)\n getNOHandler().call(\"loadCameraFromApi\", {\n player = player,\n camera = camera\n })\n end\n\n return NavigationOverlayApi\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/SoundCubeApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SoundCubeApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- this table links the name of a trigger effect to its index\n local soundIndices = {\n [\"Vacuum\"] = 0,\n [\"Deep Bell\"] = 1,\n [\"Dark Souls\"] = 2\n }\n\n ---@param index number Index of the sound effect to play\n local function playTriggerEffect(index)\n local SoundCube = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"SoundCube\")\n SoundCube.AssetBundle.playTriggerEffect(index)\n end\n\n -- plays the by name requested sound\n ---@param soundName string Name of the sound to play\n SoundCubeApi.playSoundByName = function(soundName)\n playTriggerEffect(soundIndices[soundName])\n end\n\n return SoundCubeApi\nend\nend)\n__bundle_register(\"core/token/TokenChecker\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local CHAOS_TOKEN_NAMES = {\n [\"Elder Sign\"] = true,\n [\"+1\"] = true,\n [\"0\"] = true,\n [\"-1\"] = true,\n [\"-2\"] = true,\n [\"-3\"] = true,\n [\"-4\"] = true,\n [\"-5\"] = true,\n [\"-6\"] = true,\n [\"-7\"] = true,\n [\"-8\"] = true,\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n [\"Auto-fail\"] = true,\n [\"Bless\"] = true,\n [\"Curse\"] = true,\n [\"Frost\"] = true\n }\n\n local TokenChecker = {}\n\n -- returns true if the passed object is a chaos token (by name)\n TokenChecker.isChaosToken = function(obj)\n if obj.type == \"Tile\" and CHAOS_TOKEN_NAMES[obj.getName()] then\n return true\n else\n return false\n end\n end\n\n return TokenChecker\nend\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror\n -- tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned) spawned.setState(tokenValue) end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned)\n -- token starts in state 1, so don't attempt to change it to avoid error\n if tokenValue ~= 1 then\n spawned.setState(tokenValue)\n end\n end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/Global\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal navigationOverlayApi = require(\"core/NavigationOverlayApi\")\nlocal playAreaApi = require(\"core/PlayAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal soundCubeApi = require(\"core/SoundCubeApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\nlocal tokenChecker = require(\"core/token/TokenChecker\")\nlocal tokenManager = require(\"core/token/TokenManager\")\n\n---------------------------------------------------------\n-- general setup\n---------------------------------------------------------\n\nENCOUNTER_DECK_POS = { -3.93, 1, 5.76 }\nENCOUNTER_DECK_DISCARD_POSITION = { -3.85, 1, 10.38 }\n\n-- GUIDs that will not be interactable (e.g. parts of the table)\nlocal NOT_INTERACTABLE = {\n \"6161b4\", -- Decoration-Map\n \"9f334f\", -- MythosArea\n \"463022\", -- Panel behind tentacle stand\n \"f182ee\", -- InvestigatorCount\n \"7bff34\", -- Tentacle stand\n \"8646eb\", -- horizontal border left\n \"75937e\", -- horizontal border right\n \"612072\", -- vertical border left\n \"975c39\", -- vertical border right\n}\n\nlocal chaosTokens = {}\nlocal chaosTokensLastMatGUID = nil\n\n-- chaos token stat tracking\nlocal tokenDrawingStats = { [\"Overall\"] = {} }\n\nlocal bagSearchers = {}\nlocal hideTitleSplashWaitFunctionId = nil\n\n-- online functionality related variables\nlocal MOD_VERSION = \"3.8.0\"\nlocal SOURCE_REPO = 'https://raw.githubusercontent.com/chr1z93/loadable-objects/main'\nlocal library, requestObj, modMeta\nlocal acknowledgedUpgradeVersions = {}\nlocal contentToShow = \"campaigns\"\nlocal currentListItem = 1\nlocal tabIdTable = {\n tab1 = \"campaigns\",\n tab2 = \"scenarios\",\n tab3 = \"fanmadeCampaigns\",\n tab4 = \"fanmadeScenarios\",\n tab5 = \"fanmadePlayerCards\"\n}\n\n-- optionPanel data (intentionally not local!)\noptionPanel = {}\nlocal LANGUAGES = {\n { code = \"zh_CN\", name = \"简体中文\" },\n { code = \"zh_TW\", name = \"繁體中文\" },\n { code = \"de\", name = \"Deutsch\" },\n { code = \"en\", name = \"English\" },\n { code = \"es\", name = \"Español\" },\n { code = \"fr\", name = \"Français\" },\n { code = \"it\", name = \"Italiano\" }\n}\nlocal RESOURCE_OPTIONS = {\n \"enabled\",\n \"custom\",\n \"disabled\"\n}\n\n---------------------------------------------------------\n-- data for tokens\n---------------------------------------------------------\n\nTOKEN_DATA = {\n damage = { image = \"http://cloud-3.steamusercontent.com/ugc/1758068501357115146/903D11AAE7BD5C254C8DC136E9202EE516289DEA/\", scale = { 0.17, 0.17, 0.17 } },\n horror = { image = \"http://cloud-3.steamusercontent.com/ugc/1758068501357163535/6D9E0756503664D65BDB384656AC6D4BD713F5FC/\", scale = { 0.17, 0.17, 0.17 } },\n resource = { image = \"http://cloud-3.steamusercontent.com/ugc/1758068501357192910/11DDDC7EF621320962FDCF3AE3211D5EDC3D1573/\", scale = { 0.17, 0.17, 0.17 } },\n doom = { image = \"https://i.imgur.com/EoL7yaZ.png\", scale = { 0.17, 0.17, 0.17 } },\n clue = { image = \"http://cloud-3.steamusercontent.com/ugc/1758068501357164917/1D06F1DC4D6888B6F57124BD2AFE20D0B0DA15A8/\", scale = { 0.15, 0.15, 0.15 } }\n}\n\nID_URL_MAP = {\n ['blue'] = { name = \"Elder Sign\", url = 'https://i.imgur.com/nEmqjmj.png' },\n ['p1'] = { name = \"+1\", url = 'https://i.imgur.com/uIx8jbY.png' },\n ['0'] = { name = \"0\", url = 'https://i.imgur.com/btEtVfd.png' },\n ['m1'] = { name = \"-1\", url = 'https://i.imgur.com/w3XbrCC.png' },\n ['m2'] = { name = \"-2\", url = 'https://i.imgur.com/bfTg2hb.png' },\n ['m3'] = { name = \"-3\", url = 'https://i.imgur.com/yfs8gHq.png' },\n ['m4'] = { name = \"-4\", url = 'https://i.imgur.com/qrgGQRD.png' },\n ['m5'] = { name = \"-5\", url = 'https://i.imgur.com/3Ym1IeG.png' },\n ['m6'] = { name = \"-6\", url = 'https://i.imgur.com/c9qdSzS.png' },\n ['m7'] = { name = \"-7\", url = 'https://i.imgur.com/4WRD42n.png' },\n ['m8'] = { name = \"-8\", url = 'https://i.imgur.com/9t3rPTQ.png' },\n ['skull'] = { name = \"Skull\", url = 'https://i.imgur.com/stbBxtx.png' },\n ['cultist'] = { name = \"Cultist\", url = 'https://i.imgur.com/VzhJJaH.png' },\n ['tablet'] = { name = \"Tablet\", url = 'https://i.imgur.com/1plY463.png' },\n ['elder'] = { name = \"Elder Thing\", url = 'https://i.imgur.com/ttnspKt.png' },\n ['red'] = { name = \"Auto-fail\", url = 'https://i.imgur.com/lns4fhz.png' },\n ['bless'] = { name = \"Bless\", url = 'http://cloud-3.steamusercontent.com/ugc/1655601092778627699/339FB716CB25CA6025C338F13AFDFD9AC6FA8356/' },\n ['curse'] = { name = \"Curse\", url = 'http://cloud-3.steamusercontent.com/ugc/1655601092778636039/2A25BD38E8C44701D80DD96BF0121DA21843672E/' },\n ['frost'] = { name = \"Frost\", url = 'http://cloud-3.steamusercontent.com/ugc/1858293462583104677/195F93C063A8881B805CE2FD4767A9718B27B6AE/' }\n}\n\n---------------------------------------------------------\n-- general code\n---------------------------------------------------------\n\n-- saving state of optionPanel to restore later\nfunction onSave()\n local chaosTokensGUID = {}\n for _, obj in ipairs(chaosTokens) do\n if obj ~= nil then\n table.insert(chaosTokensGUID, obj.getGUID())\n end\n end\n\n return JSON.encode({\n optionPanel = optionPanel,\n acknowledgedUpgradeVersions = acknowledgedUpgradeVersions,\n chaosTokensLastMatGUID = chaosTokensLastMatGUID,\n chaosTokensGUID = chaosTokensGUID\n })\nend\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n optionPanel = loadedData.optionPanel\n acknowledgedUpgradeVersions = loadedData.acknowledgedUpgradeVersions\n chaosTokensLastMatGUID = loadedData.chaosTokensLastMatGUID\n\n -- restore saved state for drawn chaos tokens\n for _, guid in ipairs(loadedData.chaosTokensGUID or {}) do\n table.insert(chaosTokens, getObjectFromGUID(guid))\n end\n\n updateOptionPanelState()\n end\n\n for _, guid in ipairs(NOT_INTERACTABLE) do\n local obj = getObjectFromGUID(guid)\n if obj ~= nil then obj.interactable = false end\n end\n\n getModVersion()\n math.randomseed(os.time())\n\n -- initialization of loadable objects library (delay to let Navigation Overlay build)\n Wait.time(function()\n WebRequest.get(SOURCE_REPO .. '/library.json', libraryDownloadCallback)\n end, 1)\nend\n\n-- Event hook for any object search. When chaos tokens are manipulated while the chaos bag\n-- container is being searched, a TTS bug can cause tokens to duplicate or vanish. We lock the\n-- chaos bag during search operations to avoid this.\nfunction onObjectSearchStart(object, playerColor)\n local chaosBag = findChaosBag()\n if object == chaosBag then\n bagSearchers[playerColor] = true\n end\nend\n\n-- Event hook for any object search. When chaos tokens are manipulated while the chaos bag\n-- container is being searched, a TTS bug can cause tokens to duplicate or vanish. We lock the\n-- chaos bag during search operations to avoid this.\nfunction onObjectSearchEnd(object, playerColor)\n local chaosBag = findChaosBag()\n if object == chaosBag then\n bagSearchers[playerColor] = nil\n end\nend\n\n-- Pass object enter container events to the PlayArea to clear vector lines from dragged cards.\n-- This requires the try method as cards won't exist any more after they enter a deck, so the lines\n-- can't be cleared.\nfunction tryObjectEnterContainer(container, object)\n playAreaApi.tryObjectEnterContainer(container, object)\n return true\nend\n\n-- TTS event for objects that enter zones\n-- used to detect the \"token discard zones\" beneath the hand zones\nfunction onObjectEnterZone(zone, enteringObj)\n if zone.getName() ~= \"TokenDiscardZone\" then return end\n if tokenChecker.isChaosToken(enteringObj) then return end\n\n if enteringObj.type == \"Tile\" and enteringObj.getMemo() and enteringObj.getLock() == false then\n local matcolor = playmatApi.getMatColorByPosition(enteringObj.getPosition())\n local trash = guidReferenceApi.getObjectByOwnerAndType(matcolor, \"Trash\")\n trash.putObject(enteringObj)\n end\nend\n\n-- handle card drawing via number typing for multihanded gameplay\n-- (and additionally allow Norman Withers to draw multiple cards via number)\nfunction onObjectNumberTyped(hoveredObject, playerColor, number)\n -- only continue for decks or cards\n if hoveredObject.type ~= \"Deck\" and hoveredObject.type ~= \"Card\" then return end\n\n -- check whether the hovered object is part of a players draw objects\n for _, color in ipairs(playmatApi.getUsedMatColors()) do\n local deckAreaObjects = playmatApi.getDeckAreaObjects(color)\n if deckAreaObjects.topCard == hoveredObject or deckAreaObjects.draw == hoveredObject then\n playmatApi.drawCardsWithReshuffle(color, number)\n return true\n end\n end\n\n -- check if this is a card with states (and then change state instead of drawing it)\n local states = hoveredObject.getStates()\n if states ~= nil and #states \u003e 0 then\n local stateId = hoveredObject.getStateId()\n if stateId ~= number and (#states + 1) \u003e= number then\n hoveredObject.setState(number)\n return true\n end\n end\nend\n\n---------------------------------------------------------\n-- chaos token drawing\n---------------------------------------------------------\n\n-- checks scripting zone for chaos bag (also called by a lot of objects!)\nfunction findChaosBag()\n local chaosBagZone = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"ChaosBagZone\")\n\n -- error handling: scripting zone not found\n if chaosBagZone == nil then\n printToAll(\"Zone for chaos bag detection couldn't be found.\", \"Red\")\n return\n end\n\n for _, item in ipairs(chaosBagZone.getObjects()) do\n if item.getDescription() == \"Chaos Bag\" then\n return item\n end\n end\n\n -- error handling: chaos bag not found\n printToAll(\"Chaos bag couldn't be found.\", \"Red\")\nend\n\nfunction returnChaosTokens()\n local chaosBag = findChaosBag()\n for _, token in pairs(chaosTokens) do\n if token ~= nil then chaosBag.putObject(token) end\n end\n chaosTokens = {}\nend\n\n-- returns a single chaos token to the bag and calls respective functions\nfunction returnChaosTokenToBag(token)\n local name = token.getName()\n local guid = token.getGUID()\n local chaosBag = findChaosBag()\n chaosBag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\nfunction getTokenIndex(token)\n for i, obj in ipairs(chaosTokens) do\n if obj == token then\n return i\n end\n end\nend\n\n-- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n-- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n-- contents of the bag should check this method before doing so.\n-- This method will broadcast a message to all players if the bag is being searched.\n---@return boolean: True if the bag is manipulated, false if it should be blocked.\nfunction canTouchChaosTokens()\n for _, searching in pairs(bagSearchers) do\n if searching then\n broadcastToAll(\"Someone is searching the chaos bag, can't touch the tokens.\", \"Red\")\n return false\n end\n end\n return true\nend\n\n-- converts the human readable name to the empty name that the bag uses\nfunction getChaosTokenName(tokenName)\n if tokenName == \"Custom Token\" then\n tokenName = \"\"\n end\n return tokenName\nend\n\n-- converts the empty name to the human readable name\nfunction getReadableTokenName(tokenName)\n if tokenName == \"\" then\n tokenName = \"Custom Token\"\n end\n return tokenName\nend\n\n-- called by playermats (by the \"Draw chaos token\" button)\nfunction drawChaosToken(params)\n if not canTouchChaosTokens() then return end\n\n local tokenOffset = { -1.55, 0.25, -0.58 }\n local matGUID = params.mat.getGUID()\n\n -- return token(s) on other playmat first\n if chaosTokensLastMatGUID ~= nil and chaosTokensLastMatGUID ~= matGUID and #chaosTokens ~= 0 then\n returnChaosTokens()\n chaosTokensLastMatGUID = nil\n return\n end\n\n chaosTokensLastMatGUID = matGUID\n\n -- if we have left clicked and have no tokens OR if we have right clicked\n if params.drawAdditional or #chaosTokens == 0 then\n local chaosBag = findChaosBag()\n if #chaosBag.getObjects() == 0 then return end\n chaosBag.shuffle()\n\n local indexOfReturnedToken\n local takeParameters = {}\n\n -- add the token to the list, compute new position based on list length\n if params.returnedToken then\n trackChaosToken(params.returnedToken.getName(), matGUID, true)\n indexOfReturnedToken = getTokenIndex(params.returnedToken)\n takeParameters.position = params.returnedToken.getPosition()\n if #chaosTokens \u003e indexOfReturnedToken then\n takeParameters.rotation = params.mat.getRotation() + Vector(0, 0, -8)\n else\n takeParameters.rotation = params.returnedToken.getRotation()\n end\n returnChaosTokenToBag(params.returnedToken)\n else\n tokenOffset[1] = tokenOffset[1] + (0.17 * #chaosTokens)\n takeParameters.position = params.mat.positionToWorld(tokenOffset)\n takeParameters.rotation = params.mat.getRotation()\n end\n\n local token\n if params.guidToBeResolved then\n -- resolve a sealed token from a card\n token = getObjectFromGUID(params.guidToBeResolved)\n token.setPositionSmooth(takeParameters.position)\n local guid = token.getGUID()\n local tokenType = token.getName()\n if tokenType == \"Bless\" or tokenType == \"Curse\" then\n blessCurseManagerApi.releasedToken(tokenType, guid)\n end\n tokenArrangerApi.layout()\n else\n -- take a token from the bag, either specified or random\n if params.tokenType then\n for i, lookedForToken in ipairs(chaosBag.getObjects()) do\n if lookedForToken.nickname == params.tokenType then\n takeParameters.index = i - 1\n end\n end\n end\n token = chaosBag.takeObject(takeParameters)\n end\n\n -- get data for token description\n local name = token.getName()\n local tokenData = mythosAreaApi.returnTokenData().tokenData or {}\n local specificData = tokenData[name] or {}\n token.setDescription(specificData.description or \"\")\n trackChaosToken(name, matGUID)\n\n if params.returnedToken then\n chaosTokens[indexOfReturnedToken] = token\n else\n chaosTokens[#chaosTokens + 1] = token\n end\n else\n returnChaosTokens()\n end\nend\n\n---------------------------------------------------------\n-- token spawning\n---------------------------------------------------------\n\n-- DEPRECATED. Use TokenManager instead.\n-- Spawns a single token.\n---@param params table Array with arguments to the method. 1 = position, 2 = type, 3 = rotation\nfunction spawnToken(params)\n return tokenManager.spawnToken(params[1], params[2], params[3])\nend\n\n---------------------------------------------------------\n-- chaos token stat tracker\n---------------------------------------------------------\n\nfunction trackChaosToken(tokenName, matGUID, subtract)\n -- initialize tables\n if not tokenDrawingStats[matGUID] then tokenDrawingStats[matGUID] = {} end\n\n -- increase stats by 1 (or decrease if token is returned)\n local modifier = (subtract and -1 or 1)\n\n local tokenName = getReadableTokenName(tokenName)\n tokenDrawingStats[\"Overall\"][tokenName] = (tokenDrawingStats[\"Overall\"][tokenName] or 0) + modifier\n tokenDrawingStats[matGUID][tokenName] = (tokenDrawingStats[matGUID][tokenName] or 0) + modifier\nend\n\n-- Left-click: print stats, Right-click: reset stats\nfunction handleStatTrackerClick(_, _, isRightClick)\n if isRightClick then\n resetChaosTokenStatTracker()\n else\n local squidKing = \"Nobody\"\n local maxSquid = 0\n local foundAnyStats = false\n\n for key, personalStats in pairs(tokenDrawingStats) do\n local playerColor, playerName\n\n if key == \"Overall\" then\n playerColor = \"White\"\n playerName = \"Overall\"\n else\n -- get mat color\n local matColor = playmatApi.getMatColorByPosition(getObjectFromGUID(key).getPosition())\n playerColor = playmatApi.getPlayerColor(matColor)\n playerName = Player[playerColor].steam_name or playerColor\n\n local playerSquidCount = personalStats[\"Auto-fail\"] or 0\n if playerSquidCount \u003e maxSquid then\n squidKing = playerName\n maxSquid = playerSquidCount\n end\n end\n\n -- get the total count of drawn tokens for the player\n local totalCount = 0\n for _, value in pairs(personalStats) do\n totalCount = totalCount + value\n end\n\n -- only print the personal stats if any tokens were drawn\n if totalCount \u003e 0 then\n foundAnyStats = true\n printToAll(\"------------------------------\")\n printToAll(playerName .. \" Stats\", playerColor)\n\n -- print stats in order of the \"ID_URL_MAP\"\n for _, subtable in pairs(ID_URL_MAP) do\n local tokenName = subtable.name\n local value = personalStats[tokenName]\n if value and value ~= 0 then\n printToAll(tokenName .. ': ' .. tostring(value))\n end\n end\n\n -- also print stats for custom tokens\n local customTokenName = getReadableTokenName(\"\")\n local customTokenCount = personalStats[customTokenName]\n if customTokenCount and customTokenCount ~= 0 then\n printToAll(customTokenName .. ': ' .. tostring(customTokenCount))\n end\n\n printToAll('Total: ' .. tostring(totalCount))\n end\n end\n\n -- detect if any player drew tokens\n if foundAnyStats then\n printToAll(\"------------------------------\")\n printToAll(squidKing .. \" is an auto-fail magnet.\", { 255, 0, 0 })\n else\n printToAll(\"No tokens have been drawn yet.\", \"Yellow\")\n end\n end\nend\n\n-- resets the count for each token to 0\nfunction resetChaosTokenStatTracker()\n tokenDrawingStats = { [\"Overall\"] = {} }\nend\n\n---------------------------------------------------------\n-- Difficulty selector script\n---------------------------------------------------------\n\n-- called for button creation on the difficulty selectors\n---@param args table Parameters for this function:\n-- object TTSObject Usually \"self\"\n-- key String Name of the scenario\nfunction createSetupButtons(args)\n local data = getDataValue('modeData', args.key)\n if data ~= nil then\n local buttonParameters = {}\n buttonParameters.function_owner = args.object\n buttonParameters.position = { 0, 0.1, -0.15 }\n buttonParameters.scale = { 0.47, 1, 0.47 }\n buttonParameters.height = 200\n buttonParameters.width = 1150\n buttonParameters.color = { 0.87, 0.8, 0.7 }\n\n if data.easy ~= nil then\n buttonParameters.label = \"Easy\"\n buttonParameters.click_function = \"easyClick\"\n args.object.createButton(buttonParameters)\n buttonParameters.position[3] = buttonParameters.position[3] + 0.20\n end\n\n if data.normal ~= nil then\n buttonParameters.label = \"Standard\"\n buttonParameters.click_function = \"normalClick\"\n args.object.createButton(buttonParameters)\n buttonParameters.position[3] = buttonParameters.position[3] + 0.20\n end\n\n if data.hard ~= nil then\n buttonParameters.label = \"Hard\"\n buttonParameters.click_function = \"hardClick\"\n args.object.createButton(buttonParameters)\n buttonParameters.position[3] = buttonParameters.position[3] + 0.20\n end\n\n if data.expert ~= nil then\n buttonParameters.label = \"Expert\"\n buttonParameters.click_function = \"expertClick\"\n args.object.createButton(buttonParameters)\n buttonParameters.position[3] = buttonParameters.position[3] + 0.20\n end\n\n if data.standalone ~= nil then\n buttonParameters.label = \"Standalone\"\n buttonParameters.click_function = \"standaloneClick\"\n args.object.createButton(buttonParameters)\n end\n end\nend\n\n-- called for adding chaos tokens\n---@param args table Parameters for this function:\n-- object object Usually \"self\"\n-- key string Name of the scenario\n-- mode string difficulty (e.g. \"hard\" or \"expert\")\nfunction fillContainer(args)\n local data = getDataValue('modeData', args.key)\n if data == nil then return end\n\n local value = data[args.mode]\n if value == nil or value.token == nil then return end\n\n local tokenList = {}\n\n for _, tokenId in ipairs(value.token) do\n table.insert(tokenList, tokenId)\n end\n\n if value.append ~= nil then\n for _, tokenId in ipairs(value.append) do\n table.insert(tokenList, tokenId)\n end\n end\n\n -- randomly choose tokens for specific Carcosa scenarios in standalone\n if value.random then\n local n = #value.random\n if n \u003e 0 then\n for _, tokenId in ipairs(value.random[math.random(1, n)]) do\n table.insert(tokenList, tokenId)\n end\n end\n end\n\n setChaosBagState(tokenList)\n\n if value.message then\n broadcastToAll(value.message)\n end\n\n if value.warning then\n broadcastToAll(value.warning, { 1, 0.5, 0.5 })\n end\nend\n\nfunction getDataValue(storage, key)\n local DATA_HELPER = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n local data = DATA_HELPER.getTable(storage)\n if data ~= nil then\n local value = data[key]\n if value ~= nil then\n local res = {}\n for m, v in pairs(value) do\n res[m] = v\n if res[m].parent ~= nil then\n local parentData = getDataValue(storage, res[m].parent)\n if parentData ~= nil and parentData[m] ~= nil and parentData[m].token ~= nil then\n res[m].token = parentData[m].token\n end\n res[m].parent = nil\n end\n end\n return res\n end\n end\nend\n\nfunction createChaosTokenNameLookupTable()\n local namesToIds = {}\n for k, v in pairs(ID_URL_MAP) do\n namesToIds[v.name] = k\n end\n return namesToIds\nend\n\n-- returns the currently drawn chaos tokens\n---@api ChaosBagApi\nfunction getChaosTokensinPlay()\n return chaosTokens\nend\n\n-- returns a Table List of chaos token ids in the current chaos bag\n---@api ChaosBag / ChaosBagApi\nfunction getChaosBagState()\n local tokens = {}\n local invertedTable = createChaosTokenNameLookupTable()\n local chaosBag = findChaosBag()\n\n for _, v in ipairs(chaosBag.getObjects()) do\n local id = invertedTable[v.name]\n if id then\n table.insert(tokens, id)\n else\n printToAll(v.name .. \" token not recognized. Will not be recorded.\", \"Yellow\")\n end\n end\n\n return tokens\nend\n\n-- respawns the chaos bag with a new state of tokens\n---@param tokenList table List of chaos token ids\n---@api ChaosBag / ChaosBagApi\nfunction setChaosBagState(tokenList)\n if not canTouchChaosTokens() then return end\n\n local chaosBag = findChaosBag()\n local chaosBagData = chaosBag.getData()\n local reserveData = getObjectFromGUID(\"106418\").getData()\n local tokenCache = {}\n local containedObjects = {}\n\n -- create a temporary copy of the data for each chaos token\n for _, objData in ipairs(reserveData.ContainedObjects) do\n tokenCache[objData.Nickname] = objData\n end\n\n -- iterate over tokenlist and insert specified tokens into new table\n for _, tokenId in ipairs(tokenList) do\n local tokenName = ID_URL_MAP[tokenId].name\n table.insert(containedObjects, tokenCache[tokenName])\n end\n\n -- overwrite chaos bag content and respawn it\n chaosBagData.ContainedObjects = containedObjects\n chaosBag.destruct()\n spawnObjectData({ data = chaosBagData })\n\n -- remove tokens that are still in play\n for _, token in pairs(chaosTokens) do\n if token ~= nil then token.destruct() end\n end\n chaosTokens = {}\n chaosTokensLastMatGUID = nil\n\n -- reset bless / curse manager\n blessCurseManagerApi.removeTakenTokensAndReset()\n\n printToAll(\"Chaos Bag set to chosen difficulty.\", \"Green\")\nend\n\n-- spawns the specified chaos token and puts it into the chaos bag\n---@param id string ID of the chaos token\nfunction spawnChaosToken(id)\n if not canTouchChaosTokens() then return end\n\n id = id:lower()\n local chaosBag = findChaosBag()\n local url = ID_URL_MAP[id].url or \"\"\n\n if url ~= \"\" then\n return spawnObject({\n type = 'Custom_Tile',\n position = { 0.49, 3, 0 },\n scale = { 0.81, 1.0, 0.81 },\n rotation = { 0, 270, 0 },\n callback_function = function(obj)\n obj.setName(ID_URL_MAP[id].name)\n chaosBag.putObject(obj)\n tokenArrangerApi.layout()\n end\n }).setCustomObject({\n type = 2,\n image = url,\n thickness = 0.1\n })\n end\nend\n\n-- removes the specified chaos token from the chaos bag\n---@param id string ID of the chaos token\nfunction removeChaosToken(id)\n if not canTouchChaosTokens() then return end\n\n local tokens = {}\n local chaosBag = findChaosBag()\n local name = ID_URL_MAP[id].name\n\n for _, v in ipairs(chaosBag.getObjects()) do\n if v.name == name then table.insert(tokens, v.guid) end\n end\n\n -- error handling: no matching token found\n if #tokens == 0 then\n printToAll(\"No \" .. name .. \" tokens in the chaos bag.\", \"Yellow\")\n return\n end\n\n chaosBag.takeObject({\n guid = tokens[1],\n smooth = false,\n callback_function = function(obj)\n obj.destruct()\n tokenArrangerApi.layout()\n end\n })\n printToAll(\"Removing \" .. name .. \" token (in bag: \" .. #tokens - 1 .. \")\", \"White\")\nend\n\n-- returns all sealed tokens on cards to the chaos bag\nfunction releaseAllSealedTokens(playerColor)\n for _, obj in ipairs(getObjectsWithTag(\"CardThatSeals\")) do\n obj.call(\"releaseAllTokens\", playerColor)\n end\nend\n\n---------------------------------------------------------\n-- Content Importing and XML functions\n---------------------------------------------------------\n\n-- forwards the requested content type to the update function and sets highlight to clicked tab\n---@param tabId string Id of the clicked tab\nfunction onClick_tab(_, _, tabId)\n for listId, listContent in pairs(tabIdTable) do\n if listId == tabId then\n UI.setClass(listId, 'downloadTab activeTab')\n contentToShow = listContent\n else\n UI.setClass(listId, 'downloadTab')\n end\n end\n currentListItem = 1\n updateDownloadItemList()\nend\n\n-- click function for the items in the download window\n-- updates backgroundcolor for row panel and fontcolor for list item\nfunction onClick_select(_, _, identificationKey)\n UI.setAttribute(\"panel\" .. currentListItem, \"color\", \"clear\")\n UI.setAttribute(contentToShow .. \"_\" .. currentListItem, \"color\", \"white\")\n\n -- parses the identification key (contentToShow_currentListItem)\n if identificationKey then\n contentToShow = nil\n currentListItem = nil\n for str in string.gmatch(identificationKey, \"([^_]+)\") do\n if not contentToShow then\n -- grab the first part to know the content type\n contentToShow = str\n else\n -- get the index\n currentListItem = tonumber(str)\n break\n end\n end\n end\n\n UI.setAttribute(\"panel\" .. currentListItem, \"color\", \"grey\")\n UI.setAttribute(contentToShow .. \"_\" .. currentListItem, \"color\", \"black\")\n updatePreviewWindow()\nend\n\n-- click function for the \"Custom URL\" button in the playarea image gallery\nfunction onClick_customUrl(player)\n changeWindowVisibilityForColor(player.color, \"playareaGallery\")\n Wait.time(function()\n player.showInputDialog(\"Enter a custom URL for the playarea image\", \"\", function(newURL)\n playAreaApi.updateSurface(newURL)\n end)\n end, 0.15)\nend\n\n-- click function for the download button in the preview window\nfunction onClick_download(player)\n local params = library[contentToShow][currentListItem]\n params.player = player\n placeholder_download(params)\nend\n\n-- the download button on the placeholder objects calls this to directly initiate a download\n---@param params table contains url and guid of replacement object\nfunction placeholder_download(params)\n function downloadCoroutine()\n -- show progress bar\n UI.setAttribute('download_progress', 'active', true)\n\n -- update progress bar\n while requestObj do\n UI.setAttribute('download_progress', 'percentage', requestObj.download_progress * 100)\n coroutine.yield(0)\n end\n UI.setAttribute('download_progress', 'percentage', 100)\n\n -- wait 30 frames\n for i = 1, 30 do\n coroutine.yield(0)\n end\n\n -- hide progress bar\n UI.setAttribute('download_progress', 'active', false)\n\n -- hide download window\n if params.player then\n changeWindowVisibilityForColor(params.player.color, \"downloadWindow\", false)\n end\n return 1\n end\n\n local url = SOURCE_REPO .. '/' .. params.url\n requestObj = WebRequest.get(url, function(request) contentDownloadCallback(request, params) end)\n startLuaCoroutine(Global, 'downloadCoroutine')\nend\n\n-- spawns a bag that contains every object from the library\nfunction onClick_downloadAll(player)\n broadcastToAll(\"Download initiated - this will take a few minutes!\")\n\n -- hide download window\n changeWindowVisibilityForColor(player.color, \"downloadWindow\", false)\n\n startLuaCoroutine(Global, \"coroutineDownloadAll\")\nend\n\nfunction coroutineDownloadAll()\n local JSON = [[\n {\n \"Name\": \"Bag\",\n \"Transform\": {\n \"posX\": {{POSX}},\n \"posY\": 2,\n \"posZ\": -95,\n \"rotX\": 0,\n \"rotY\": 270,\n \"rotZ\": 0,\n \"scaleX\": 1,\n \"scaleY\": 1,\n \"scaleZ\": 1\n },\n \"Nickname\": \"{{NICKNAME}}\",\n \"Bag\": {\n \"Order\": 0\n },\n \"ContainedObjects\": [\n ]]\n\n local posx = -45.0\n local downloadedItems = 0\n local skippedItems = 0\n\n -- loop through the library to add content\n for contentType, objectList in pairs(library) do\n broadcastToAll(\"Downloading \" .. contentType .. \"...\")\n local contained = \"\"\n for _, params in ipairs(objectList) do\n local request = WebRequest.get(SOURCE_REPO .. '/' .. params.url, function() end)\n local start = os.time()\n while true do\n if request.is_done then\n contained = contained .. request.text .. \",\"\n downloadedItems = downloadedItems + 1\n break\n -- time-out if item can't be loaded in 5s\n elseif request.is_error or (os.time() - start) \u003e 5 then\n skippedItems = skippedItems + 1\n break\n end\n coroutine.yield(0)\n end\n end\n local JSONCopy = JSON\n JSONCopy = JSONCopy .. contained .. \"]}\"\n JSONCopy = JSONCopy:gsub(\"{{POSX}}\", posx)\n JSONCopy = JSONCopy:gsub(\"{{NICKNAME}}\", contentType)\n spawnObjectJSON({ json = JSONCopy })\n posx = posx + 3\n end\n\n broadcastToAll(downloadedItems .. \" objects downloaded.\", \"Green\")\n broadcastToAll(skippedItems .. \" objects had a time-out / error.\", \"Orange\")\n return 1\nend\n\n-- spawns a placeholder box for the selected object\nfunction onClick_spawnPlaceholder(player)\n -- get object references\n local item = library[contentToShow][currentListItem]\n local dummy = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlaceholderBoxDummy\")\n\n -- error handling\n if not item.boxsize or item.boxsize == \"\" or not item.boxart or item.boxart == \"\" then\n print(\"Error loading object.\")\n return\n end\n\n -- get data for placeholder\n local spawnPos = { -39.5, 2, -87 }\n\n local meshTable = {\n big = \"https://raw.githubusercontent.com/RobMayer/TTSLibrary/master/advboxes/core_h_MSH.obj\",\n small = \"https://raw.githubusercontent.com/RobMayer/TTSLibrary/master/advboxes/tuckbox_h_MSH.obj\",\n wide = \"http://cloud-3.steamusercontent.com/ugc/2278324073260846176/33EFCAF30567F8756F665BE5A2A6502E9C61C7F7/\"\n }\n\n local scaleTable = {\n big = { 1.00, 0.14, 1.00 },\n small = { 2.21, 0.46, 2.42 },\n wide = { 2.00, 0.11, 1.69 }\n }\n\n local placeholder = spawnObject({\n type = \"Custom_Model\",\n position = spawnPos,\n rotation = { 0, 270, 0 },\n scale = scaleTable[item.boxsize],\n })\n\n placeholder.setCustomObject({\n mesh = meshTable[item.boxsize],\n diffuse = item.boxart,\n material = 3\n })\n\n if item.boxsize == \"big\" then\n placeholder.addTag(\"LargeBox\")\n end\n\n placeholder.setColorTint({ 1, 1, 1, 71 / 255 })\n placeholder.setName(item.name)\n placeholder.setDescription(\"by \" .. (item.author or \"Unknown\"))\n placeholder.setGMNotes(item.url)\n placeholder.setLuaScript(dummy.getLuaScript())\n Player.getPlayers()[1].pingTable(spawnPos)\n\n -- hide download window\n changeWindowVisibilityForColor(player.color, \"downloadWindow\", false)\nend\n\n-- toggles the visibility of the respective UI\n---@param player tts__Player Player that triggered this\n---@param windowId string Name of the UI to toggle\nfunction onClick_toggleUi(player, windowId)\n if windowId == \"Navigation Overlay\" then\n navigationOverlayApi.cycleVisibility(player.color)\n return\n end\n\n -- hide the playAreaGallery if visible\n if windowId == \"downloadWindow\" then\n changeWindowVisibilityForColor(player.color, \"playAreaGallery\", false)\n -- hide the downloadWindow if visible\n elseif windowId == \"playAreaGallery\" then\n changeWindowVisibilityForColor(player.color, \"downloadWindow\", false)\n end\n\n changeWindowVisibilityForColor(player.color, windowId)\nend\n\n-- toggles the visibility of the specific window for the specified color\n---@param color string Player color to toggle the visibility for\n---@param windowId string ID of the XML element\n---@param overrideState? boolean Forcefully sets the new visibility\n---@return boolean visible Returns the new state of the visibility\nfunction changeWindowVisibilityForColor(color, windowId, overrideState)\n -- current state\n local colorString = UI.getAttribute(windowId, \"visibility\") or \"\"\n\n -- parse the visibility string\n local visible = false\n local viewers = {}\n for str in string.gmatch(colorString, \"%a+\") do\n table.insert(viewers, str)\n if str == color then\n visible = true\n end\n end\n\n -- add / remove the color as viewer\n if visible == true then\n removeValueFromTable(viewers, color)\n elseif visible == false then\n table.insert(viewers, color)\n end\n visible = not visible\n\n -- resolve override\n if overrideState == true and visible == false then\n table.insert(viewers, color)\n visible = true\n elseif overrideState == false and visible == true then\n removeValueFromTable(viewers, color)\n visible = false\n end\n\n -- construct new string\n local newColorString = \"\"\n for _, viewer in ipairs(viewers) do\n newColorString = newColorString .. viewer .. \"|\"\n end\n\n -- remove last delimiter\n newColorString = newColorString:sub(1, -2)\n\n -- update the visibility of the XML\n UI.setAttribute(windowId, \"visibility\", newColorString)\n UI.setAttribute(windowId, \"active\", newColorString ~= \"\")\n\n return visible\nend\n\n-- forwards the call to the onClick function\nfunction togglePlayAreaGallery(playerColor)\n changeWindowVisibilityForColor(playerColor, \"playareaGallery\")\nend\n\n-- updates the preview window\nfunction updatePreviewWindow()\n local item = library[contentToShow][currentListItem]\n local tempImage =\n \"http://cloud-3.steamusercontent.com/ugc/2115061845788345842/2CD6ABC551555CCF58F9D0DDB7620197BA398B06/\"\n\n -- set default image if not defined\n if item.boxsize == nil or item.boxsize == \"\" or item.boxart == nil or item.boxart == \"\" then\n item.boxsize = \"big\"\n item.boxart = \"http://cloud-3.steamusercontent.com/ugc/762723517667628371/18438B0A0045038A7099648AA3346DFCAA267C66/\"\n end\n\n UI.setValue(\"previewTitle\", item.name)\n UI.setValue(\"previewAuthor\", \"by \" .. (item.author or \"- Author not found -\"))\n UI.setValue(\"previewDescription\", item.description or \"- Description not found -\")\n\n -- update mask according to size (hardcoded values to align image in mask)\n local maskData = {}\n if item.boxsize == \"big\" then\n maskData = {\n image = \"box-cover-mask-big\",\n width = \"870\",\n height = \"435\",\n offsetXY = \"154 60\"\n }\n elseif item.boxsize == \"small\" then\n maskData = {\n image = \"box-cover-mask-small\",\n width = \"792\",\n height = \"594\",\n offsetXY = \"135 13\"\n }\n elseif item.boxsize == \"wide\" then\n maskData = {\n image = \"box-cover-mask-wide\",\n width = \"756\",\n height = \"630\",\n offsetXY = \"-190 -70\"\n }\n end\n\n -- loading empty image as placeholder until real image is loaded\n UI.setAttribute(\"previewArtImage\", \"image\", tempImage)\n\n -- insert the image itself\n UI.setAttribute(\"previewArtImage\", \"image\", item.boxart)\n UI.setAttributes(\"previewArtMask\", maskData)\nend\n\n-- formats the json response from the webrequest into a key-value lua table\n-- strips the prefix from the community content items\nfunction formatLibrary(json_response)\n library = {}\n library[\"campaigns\"] = json_response.campaigns\n library[\"scenarios\"] = json_response.scenarios\n library[\"extras\"] = json_response.extras\n library[\"fanmadeCampaigns\"] = {}\n library[\"fanmadeScenarios\"] = {}\n library[\"fanmadePlayerCards\"] = {}\n\n for _, item in ipairs(json_response.community) do\n local identifier = nil\n for str in string.gmatch(item.name, \"([^:]+)\") do\n if not identifier then\n -- grab the first part to know the content type\n identifier = str\n else\n -- update the name without the content type\n item.name = str\n break\n end\n end\n\n if identifier == \"Fan Investigators\" then\n table.insert(library[\"fanmadePlayerCards\"], item)\n elseif identifier == \"Fan Campaign\" then\n table.insert(library[\"fanmadeCampaigns\"], item)\n elseif identifier == \"Fan Scenario\" then\n table.insert(library[\"fanmadeScenarios\"], item)\n end\n end\nend\n\n-- updates the window content to the requested content\nfunction updateDownloadItemList()\n if not library then return end\n\n -- addition of list items according to library file\n local globalXml = UI.getXmlTable()\n local contentList = getXmlTableElementById(globalXml, 'contentList')\n\n contentList.children = {}\n for i, v in ipairs(library[contentToShow]) do\n table.insert(contentList.children,\n {\n tag = \"Panel\",\n attributes = { id = \"panel\" .. i },\n children = {\n tag = 'Text',\n value = v.name,\n attributes = {\n id = contentToShow .. \"_\" .. i,\n onClick = 'onClick_select',\n alignment = 'MiddleLeft'\n }\n }\n })\n end\n\n contentList.attributes.height = #contentList.children * 27\n updateGlobalXml(globalXml)\n\n -- select the first item\n Wait.time(onClick_select, 0.2)\nend\n\n-- this helper function updates the global XML while preserving the visibility of windows\nfunction updateGlobalXml(newXml)\n -- preserve visibility settings for these elements\n local windowIdList = {\n \"playAreaGallery\",\n \"downloadWindow\",\n \"optionPanel\"\n }\n\n -- get current state and update newXml\n for _, windowId in ipairs(windowIdList) do\n local element = getXmlTableElementById(newXml, windowId)\n element.attributes.active = UI.getAttribute(windowId, \"active\")\n element.attributes.visibility = UI.getAttribute(windowId, \"visibility\")\n end\n\n UI.setXmlTable(newXml)\nend\n\n-- called after the webrequest of downloading an item\n-- deletes the placeholder and spawns the downloaded item\nfunction contentDownloadCallback(request, params)\n requestObj = nil\n\n -- error handling\n if request.is_error or request.response_code ~= 200 then\n print('Error: ' .. request.error)\n return\n end\n\n -- initiate content spawning\n local spawnTable = { json = request.text }\n if params.replace then\n local replacedObject = getObjectFromGUID(params.replace)\n if replacedObject then\n spawnTable.position = replacedObject.getPosition()\n spawnTable.rotation = replacedObject.getRotation()\n spawnTable.scale = replacedObject.getScale()\n destroyObject(replacedObject)\n end\n end\n\n -- if position is undefined, get empty position\n if not spawnTable.position then\n spawnTable.rotation = { 0, 270, 0 }\n\n local pos = getValidSpawnPosition()\n if pos then\n spawnTable.position = pos\n else\n broadcastToAll(\"Please make space in the area below the tentacle stand in the upper middle of the table and try again.\", \"Red\")\n return\n end\n end\n\n -- if spawned from menu, move the camera and/or ping the table\n if params.name then\n spawnTable[\"callback_function\"] = function(obj)\n Wait.time(function()\n -- move camera\n if params.player then\n params.player.lookAt({\n position = obj.getPosition(),\n pitch = 65,\n yaw = 90,\n distance = 65\n })\n end\n\n -- ping object\n local pingPlayer = params.player or Player.getPlayers()[1]\n pingPlayer.pingTable(obj.getPosition())\n end, 0.1)\n end\n end\n\n if pcall(function() spawnObjectJSON(spawnTable) end) then\n print('Object loaded.')\n else\n print('Error loading object.')\n end\nend\n\n-- gets the first empty position to spawn a custom content object safely\nfunction getValidSpawnPosition()\n local potentialSpawnPositionX = { 65, 50, 35 }\n local potentialSpawnPositionY = 1.5\n local potentialSpawnPositionZ = { 35, 21, 7, -7, -21, -35 }\n\n for i, posX in ipairs(potentialSpawnPositionX) do\n for j, posZ in ipairs(potentialSpawnPositionZ) do\n local pos = {\n x = posX,\n y = potentialSpawnPositionY,\n z = posZ,\n }\n if checkPositionForContentSpawn(pos) then\n return pos\n end\n end\n end\n return nil\nend\n\n-- checks whether something is in the specified position\n-- returns true if empty\nfunction checkPositionForContentSpawn(checkPos)\n local searchResult = searchLib.atPosition(checkPos)\n\n -- first hit is the table surface, additional hits means something is there\n return #searchResult == 1\nend\n\n-- downloading of the library file\nfunction libraryDownloadCallback(request)\n if request.is_error or request.response_code ~= 200 then\n print('error: ' .. request.error)\n return\n end\n\n local json_response = nil\n if pcall(function() json_response = JSON.decode(request.text) end) then\n formatLibrary(json_response)\n updateDownloadItemList()\n else\n print('error parsing downloaded library')\n end\nend\n\n-- loops through an XML table and returns the specified object\n---@param ui table XmlTable (get this via getXmlTable)\n---@param id string Id of the object to return\nfunction getXmlTableElementById(ui, id)\n for _, obj in ipairs(ui) do\n if obj.attributes and obj.attributes.id and obj.attributes.id == id then return obj end\n if obj.children then\n local result = getXmlTableElementById(obj.children, id)\n if result then return result end\n end\n end\n return nil\nend\n\n---------------------------------------------------------\n-- Option Panel related functionality\n---------------------------------------------------------\n\n-- changes the UI state and the internal variable for the togglebuttons\nfunction onClick_toggleOption(_, _, id)\n local currentState = optionPanel[id]\n local newState = not currentState\n applyOptionPanelChange(id, newState)\n UI.setAttribute(id, \"image\", newState and \"option-on\" or \"option-off\")\nend\n\n-- color selection for playArea\nfunction onClick_playAreaConnectionColor(player, _, id)\n player.showColorDialog(optionPanel[id], function(color)\n applyOptionPanelChange(id, color)\n end)\nend\n\n-- called by the language selection dropdown\nfunction languageSelected(_, selectedIndex, id)\n optionPanel[id] = LANGUAGES[tonumber(selectedIndex) + 1].code\nend\n\n-- returns the ID (position in the table) for a provided language code\nfunction returnLanguageId(code)\n for index, tbl in ipairs(LANGUAGES) do\n if tbl.code == code then\n return index\n end\n end\nend\n\n-- called by the resource counter selection dropdown\nfunction resourceCounterSelected(_, selectedIndex, id)\n optionPanel[id] = RESOURCE_OPTIONS[tonumber(selectedIndex) + 1]\nend\n\n-- returns the ID for the provided option name\nfunction returnResourceCounterId(name)\n for index, optionName in ipairs(RESOURCE_OPTIONS) do\n if optionName == name then\n return index\n end\n end\nend\n\n-- called by the playermat removal selection dropdown\nfunction playermatRemovalSelected(player, selectedIndex, id)\n if selectedIndex == \"0\" then return end\n\n local matColorList = { \"White\", \"Orange\", \"Green\", \"Red\" }\n local matColor = matColorList[tonumber(selectedIndex)]\n local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\")\n\n if mat then\n -- confirmation dialog about deletion\n player.pingTable(mat.getPosition())\n player.showConfirmDialog(\"Do you really want to remove \" .. matColor .. \"'s playermat and related objects? This can't be reversed.\", function() removePlayermat(matColor) end)\n else\n -- info dialog that it is already deleted\n player.showInfoDialog(matColor .. \"'s playermat has already been removed.\")\n end\n\n -- set selected value back to first option\n UI.setAttribute(id, \"value\", 0)\nend\n\n-- removes a playermat and all related objects from play\n---@param matColor string Color of the playermat to remove\nfunction removePlayermat(matColor)\n local matObjects = guidReferenceApi.getObjectsByOwner(matColor)\n if not matObjects.Playermat then return end\n\n -- remove action tokens\n local actionTokens = playmatApi.searchAroundPlaymat(matColor, \"isActionToken\")\n for _, obj in ipairs(actionTokens) do\n obj.destruct()\n end\n\n -- remove mat owned objects\n for _, obj in pairs(matObjects) do\n obj.destruct()\n end\nend\n\n-- sets the option panel to the correct state (corresponding to 'optionPanel')\nfunction updateOptionPanelState()\n for id, optionValue in pairs(optionPanel) do\n if id == \"cardLanguage\" and type(optionValue) == \"string\" then\n local dropdownId = returnLanguageId(optionValue) - 1\n UI.setAttribute(id, \"value\", dropdownId)\n elseif id == \"useResourceCounters\" and type(optionValue) == \"string\" then\n local dropdownId = returnResourceCounterId(optionValue) - 1\n UI.setAttribute(id, \"value\", dropdownId)\n elseif id == \"playAreaConnectionColor\" then\n UI.setAttribute(id, \"color\", \"#\" .. Color.new(optionValue):toHex())\n elseif (type(optionValue) == \"boolean\" and optionValue)\n or (type(optionValue) == \"string\" and optionValue)\n or (type(optionValue) == \"table\" and #optionValue ~= 0) then\n UI.setAttribute(id, \"image\", \"option-on\")\n else\n UI.setAttribute(id, \"image\", \"option-off\")\n end\n end\nend\n\n-- handles the applying of option selections and calls the respective functions based on the id\n---@param id string ID of the option that was selected or deselected\n---@param state boolean|any State of the option (true = enabled)\nfunction applyOptionPanelChange(id, state)\n optionPanel[id] = state\n\n -- option: Snap tags\n if id == \"useSnapTags\" then\n playmatApi.setLimitSnapsByType(state, \"All\")\n\n -- option: Draw 1 button\n elseif id == \"showDrawButton\" then\n playmatApi.showDrawButton(state, \"All\")\n\n -- option: Clickable clue counters\n elseif id == \"useClueClickers\" then\n playmatApi.clickableClues(state, \"All\")\n\n -- update master clue counter\n local counter = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MasterClueCounter\")\n counter.setVar(\"useClickableCounters\", state)\n\n -- option: Play area snap tags\n elseif id == \"playAreaConnections\" then\n playAreaApi.setConnectionDrawState(state)\n\n -- option: Play area connection color\n elseif id == \"playAreaConnectionColor\" then\n playAreaApi.setConnectionColor(state)\n UI.setAttribute(id, \"color\", \"#\" .. Color.new(state):toHex())\n\n -- option: Play area snap tags\n elseif id == \"playAreaSnapTags\" then\n playAreaApi.setLimitSnapsByType(state)\n\n -- option: Show clean up helper\n elseif id == \"showCleanUpHelper\" then\n spawnOrRemoveHelper(state, \"Clean Up Helper\", { -66, 1.6, 46 })\n\n -- option: Show hand helper for each player\n elseif id == \"showHandHelper\" then\n spawnOrRemoveHelperForPlayermats(\"Hand Helper\", state)\n\n -- option: Show search assistant for each player\n elseif id == \"showSearchAssistant\" then\n spawnOrRemoveHelperForPlayermats(\"Search Assistant\", state)\n\n -- option: Show attachment helper\n elseif id == \"showAttachmentHelper\" then\n spawnOrRemoveHelper(state, \"Attachment Helper\", { -62, 1.4, 0 })\n\n -- option: Show CYOA campaign guides\n elseif id == \"showCYOA\" then\n spawnOrRemoveHelper(state, \"CYOA Campaign Guides\", { 39, 1.3, -20 })\n\n -- option: Show displacement tool\n elseif id == \"showDisplacementTool\" then\n spawnOrRemoveHelper(state, \"Displacement Tool\", { -57, 1.6, 46 })\n end\nend\n\n-- spawns or removes a helper object for all playermats\n---@param helperName string Name of the helper object\n---@param state boolean Contains the state of the option: true = spawn it, false = remove it\nfunction spawnOrRemoveHelperForPlayermats(helperName, state)\n for color, data in pairs(playmatApi.getHelperSpawnData(\"All\", helperName)) do\n spawnOrRemoveHelper(state, helperName, data.position, data.rotation, color)\n end\nend\n\n-- handler for spawn / remove functions of helper objects\n---@param state boolean Contains the state of the option: true = spawn it, false = remove it\n---@param name string Name of the helper object\n---@param position tts__Vector Position of the object (where it will spawn)\n---@param rotation? tts__Vector Rotation of the object for spawning (default: {0, 270, 0})\n---@param owner? string Owner of the object (defaults to \"Mythos\")\n---@return string|nil GUID GUID of the spawnedObj (or nil if object was removed)\nfunction spawnOrRemoveHelper(state, name, position, rotation, owner)\n if state then\n Player.getPlayers()[1].pingTable(position)\n local spawnedGUID = spawnHelperObject(name, position, rotation).getGUID()\n local cleanName = name:gsub(\"%s+\", \"\")\n guidReferenceApi.editIndex(owner or \"Mythos\", cleanName, spawnedGUID)\n else\n removeHelperObject(name)\n end\nend\n\n-- copies the specified tool (by name) from the option panel source bag\n---@param name string Name of the object that should be copied\n---@param position tts__Vector Desired position of the object\n---@param rotation? tts__Vector Desired rotation of the object (defaults to object's rotation)\nfunction spawnHelperObject(name, position, rotation)\n local sourceBag = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"OptionPanelSource\")\n\n -- error handling for missing sourceBag\n if not sourceBag then\n broadcastToAll(\"Option panel source bag could not be found!\", \"Red\")\n return\n end\n\n local spawnTable = { position = position }\n\n -- only overrride rotation if there is one provided (object's rotation used instead)\n if rotation then\n spawnTable.rotation = rotation\n end\n\n for _, obj in ipairs(sourceBag.getData().ContainedObjects) do\n if obj[\"Nickname\"] == name then\n spawnTable.data = obj\n spawnTable.callback_function = function(spawnedObj)\n Wait.time(function() spawnedObj.setLock(true) end, 2)\n end\n return spawnObjectData(spawnTable)\n end\n end\nend\n\n-- removes the specified tool (by name)\n---@param name string Object that should be removed\nfunction removeHelperObject(name)\n local cleanName = name:gsub(\"%s+\", \"\")\n for _, obj in pairs(guidReferenceApi.getObjectsByType(cleanName)) do\n obj.destruct()\n end\nend\n\n-- loads saved options\n---@param newOptions table Contains the new state for the option panel\nfunction loadSettings(newOptions)\n for id, state in pairs(newOptions) do\n if optionPanel[id] ~= state then\n optionPanel[id] = state\n applyOptionPanelChange(id, state)\n end\n end\n\n -- update XML UI state\n updateOptionPanelState()\nend\n\n-- loads the default options\nfunction onClick_defaultSettings()\n -- clean reset of variables\n optionPanel = {\n cardLanguage = \"en\",\n changePlayAreaImage = false,\n playAreaConnectionColor = { a = 1, b = 0.4, g = 0.4, r = 0.4 },\n playAreaConnections = true,\n playAreaSnapTags = true,\n showAttachmentHelper = false,\n showCleanUpHelper = false,\n showCYOA = false,\n showDisplacementTool = false,\n showDrawButton = false,\n showHandHelper = false,\n showSearchAssistant = false,\n showTitleSplash = true,\n useClueClickers = false,\n useResourceCounters = \"disabled\",\n useSnapTags = true\n }\n\n -- applying changes\n for id, state in pairs(optionPanel) do\n applyOptionPanelChange(id, state)\n end\n\n -- update UI\n updateOptionPanelState()\nend\n\n-- splash scenario title on setup\nfunction titleSplash(scenarioName)\n if optionPanel['showTitleSplash'] then\n -- if there's any ongoing title being displayed, hide it and cancel the waiting function\n if hideTitleSplashWaitFunctionId then\n Wait.stop(hideTitleSplashWaitFunctionId)\n hideTitleSplashWaitFunctionId = nil\n UI.setAttribute('title_splash', 'active', false)\n end\n\n -- display scenario name and set a 4 seconds (2 seconds animation and 2 seconds on screen)\n -- wait timer to hide the scenario name\n UI.setValue('title_splash_text', scenarioName)\n UI.show('title_splash')\n hideTitleSplashWaitFunctionId = Wait.time(function()\n UI.hide('title_splash')\n hideTitleSplashWaitFunctionId = nil\n end, 4)\n\n soundCubeApi.playSoundByName(\"Deep Bell\")\n end\nend\n\n---------------------------------------------------------\n-- Update notification related functionality\n---------------------------------------------------------\n\n-- grabs the latest mod version and release notes from GitHub (called onLoad())\nfunction getModVersion()\n WebRequest.get(SOURCE_REPO .. '/modversion.json', compareVersion)\nend\n\n-- compares the modversion with GitHub and possibly shows the update notification\nfunction compareVersion(request)\n if request.is_error then\n log(request.error)\n return\n end\n\n -- global variable to make it accessible for other functions\n modMeta = JSON.decode(request.text)\n\n -- stop here if on latest or newer version\n if convertVersionToNumber(MOD_VERSION) \u003e= convertVersionToNumber(modMeta[\"latestVersion\"]) then return end\n\n -- stop here if \"don't show again\" was clicked for this version before\n if acknowledgedUpgradeVersions[modMeta[\"latestVersion\"]] then return end\n\n updateNotificationLoading()\n\n -- delay to avoid lagging during onLoad()\n Wait.time(function() UI.show(\"FinnIcon\") end, 1)\nend\n\n-- converts a version number to a string\n---@param version string Version number, separated by dots (e.g. 3.3.1)\nfunction convertVersionToNumber(version)\n local major, minor, patch = string.match(version, \"(%d+)%.(%d+)%.(%d+)\")\n return major * 100 + minor * 10 + patch\nend\n\n-- updates the XML update notification based on the mod metadata\nfunction updateNotificationLoading()\n -- grab data\n local highlights = modMeta[\"releaseHighlights\"]\n\n -- concatenate the release highlights\n local highlightText = \"• \" .. highlights[1]\n for i, entry in pairs(highlights) do\n if i ~= 1 then\n highlightText = highlightText .. \"\\n• \" .. entry\n end\n end\n\n -- update the XML UI\n UI.setValue(\"notificationHeader\", \"New version available: \" .. modMeta[\"latestVersion\"])\n UI.setValue(\"releaseHighlightText\", highlightText)\n UI.setAttribute(\"highlightRow\", \"preferredHeight\", 20 * #highlights)\n UI.setAttribute(\"updateNotification\", \"height\", 20 * #highlights + 125)\nend\n\n-- close / don't show again buttons on the update notification\nfunction onClick_notification(_, parameter)\n if parameter == \"dontShowAgain\" then\n -- this variable tracks if \"don't show again\" was pressed for a version\n acknowledgedUpgradeVersions[modMeta[\"latestVersion\"]] = true\n end\n UI.hide(\"FinnIcon\")\n UI.hide(\"updateNotification\")\nend\n\n---------------------------------------------------------\n-- Utility functions\n---------------------------------------------------------\n\nfunction removeValueFromTable(t, val)\n for i, v in ipairs(t) do\n if v == val then\n table.remove(t, i)\n break\n end\n end\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat to the first empty spot from the right \n ---@param matColor string Playermat that triggered this\n ---@param position tts__Vector Position for the encounter card\n MythosAreaApi.drawEncounterCard = function(matColor, position)\n getMythosArea().call(\"drawEncounterCard\", { matColor = matColor, position = position })\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"core/NavigationOverlayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local NavigationOverlayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getNOHandler()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"NavigationOverlayHandler\")\n end\n\n -- copies the visibility for the Navigation overlay\n ---@param startColor string Color of the player to copy from\n ---@param targetColor string Color of the targeted player\n NavigationOverlayApi.copyVisibility = function(startColor, targetColor)\n getNOHandler().call(\"copyVisibility\", {\n startColor = startColor,\n targetColor = targetColor\n })\n end\n\n -- changes the Navigation Overlay view (\"Full View\" --\u003e \"Play Areas\" --\u003e \"Closed\" etc.)\n ---@param playerColor string Color of the player to update the visibility for\n NavigationOverlayApi.cycleVisibility = function(playerColor)\n getNOHandler().call(\"cycleVisibility\", playerColor)\n end\n\n -- loads the specified camera for a player\n ---@param player tts__Player Player whose camera should be moved\n ---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to\n NavigationOverlayApi.loadCamera = function(player, camera)\n getNOHandler().call(\"loadCameraFromApi\", {\n player = player,\n camera = camera\n })\n end\n\n return NavigationOverlayApi\nend\nend)\n__bundle_register(\"core/token/TokenChecker\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local CHAOS_TOKEN_NAMES = {\n [\"Elder Sign\"] = true,\n [\"+1\"] = true,\n [\"0\"] = true,\n [\"-1\"] = true,\n [\"-2\"] = true,\n [\"-3\"] = true,\n [\"-4\"] = true,\n [\"-5\"] = true,\n [\"-6\"] = true,\n [\"-7\"] = true,\n [\"-8\"] = true,\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n [\"Auto-fail\"] = true,\n [\"Bless\"] = true,\n [\"Curse\"] = true,\n [\"Frost\"] = true\n }\n\n local TokenChecker = {}\n\n -- returns true if the passed object is a chaos token (by name)\n TokenChecker.isChaosToken = function(obj)\n if obj.type == \"Tile\" and CHAOS_TOKEN_NAMES[obj.getName()] then\n return true\n else\n return false\n end\n end\n\n return TokenChecker\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/Global\")\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/SoundCubeApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SoundCubeApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- this table links the name of a trigger effect to its index\n local soundIndices = {\n [\"Vacuum\"] = 0,\n [\"Deep Bell\"] = 1,\n [\"Dark Souls\"] = 2\n }\n\n ---@param index number Index of the sound effect to play\n local function playTriggerEffect(index)\n local SoundCube = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"SoundCube\")\n SoundCube.AssetBundle.playTriggerEffect(index)\n end\n\n -- plays the by name requested sound\n ---@param soundName string Name of the sound to play\n SoundCubeApi.playSoundByName = function(soundName)\n playTriggerEffect(soundIndices[soundName])\n end\n\n return SoundCubeApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "{\"acknowledgedUpgradeVersions\":[],\"chaosTokensGUID\":[],\"optionPanel\":{\"cardLanguage\":\"en\",\"changePlayAreaImage\":false,\"playAreaConnectionColor\":{\"a\":1,\"b\":0.4,\"g\":0.4,\"r\":0.4},\"playAreaConnections\":true,\"playAreaSnapTags\":true,\"showAttachmentHelper\":false,\"showCleanUpHelper\":false,\"showCYOA\":false,\"showDisplacementTool\":false,\"showDrawButton\":false,\"showHandHelper\":false,\"showSearchAssistant\":false,\"showTitleSplash\":true,\"useClueClickers\":false,\"useResourceCounters\":\"disabled\",\"useSnapTags\":true}}", "MusicPlayer": { "AudioLibrary": [ @@ -580,7 +590,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GUIDReferenceHandler\")\nend)\n__bundle_register(\"core/GUIDReferenceHandler\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal GuidReferences = {\n White = {\n ClueCounter = \"d86b7c\",\n ClickableClueCounter = \"db85d6\",\n DamageCounter = \"eb08d6\",\n HandZone = \"a70eee\",\n HorrorCounter = \"468e88\",\n InvestigatorSkillTracker = \"e598c2\",\n Playermat = \"8b081b\",\n ResourceCounter = \"4406f0\",\n TokenDiscardZone = \"457de3\",\n Trash = \"147e80\"\n },\n Orange = {\n ClueCounter = \"1769ed\",\n ClickableClueCounter = \"3f22e5\",\n DamageCounter = \"e64eec\",\n HandZone = \"5fe087\",\n HorrorCounter = \"0257d9\",\n InvestigatorSkillTracker = \"b4a5f7\",\n Playermat = \"bd0ff4\",\n ResourceCounter = \"816d84\",\n TokenDiscardZone = \"457de4\",\n Trash = \"f7b6c8\"\n },\n Green = {\n ClueCounter = \"032300\",\n ClickableClueCounter = \"891403\",\n DamageCounter = \"1f5a0a\",\n HandZone = \"0285cc\",\n HorrorCounter = \"7b5729\",\n InvestigatorSkillTracker = \"af7ed7\",\n PoolResources = \"0168ae\",\n PoolDamage = \"b0ef6c\",\n PoolHorror = \"ae1a4e\",\n PoolClues = \"fae2f6\",\n PoolDoom = \"16724b\",\n Playermat = \"383d8b\",\n ResourceCounter = \"cd15ac\",\n TokenDiscardZone = \"457de5\",\n TokenRemover = \"2ba7a5\",\n Trash = \"5f896a\"\n },\n Red = {\n ClueCounter = \"37be78\",\n ClickableClueCounter = \"4111de\",\n DamageCounter = \"591a45\",\n HandZone = \"be2f17\",\n HorrorCounter = \"beb964\",\n InvestigatorSkillTracker = \"e74881\",\n PoolResources = \"fd617a\",\n PoolDamage = \"93f4a0\",\n PoolHorror = \"7bd2a0\",\n PoolClues = \"3b2550\",\n PoolDoom = \"16fcd6\",\n Playermat = \"0840d5\",\n ResourceCounter = \"a4b60d\",\n TokenDiscardZone = \"457de6\",\n TokenRemover = \"39b175\",\n Trash = \"4b8594\"\n },\n Mythos = {\n AdditionalPlayerCardsBag = \"2cba6b\",\n AllCardsBag = \"15bb07\",\n BlessCurseManager = \"5933fb\",\n CampaignThePathToCarcosa = \"aca04c\",\n ChaosBagZone = \"83ef06\",\n DataHelper = \"708279\",\n DeckImporter = \"a28140\",\n DoomCounter = \"85c4c6\",\n DoomInPlayCounter = \"652ff3\",\n InvestigatorCounter = \"f182ee\",\n MasterClueCounter = \"4a3aa4\",\n MythosArea = \"9f334f\",\n NavigationOverlayHandler = \"797ede\",\n OptionPanelSource = \"830bd0\",\n PlaceholderBoxDummy = \"a93466\",\n PlayArea = \"721ba2\",\n PlayAreaImageSelector = \"b7b45b\",\n PlayAreaZone = \"a2f932\",\n PlayerCardPanel = \"2d30ee\",\n ResourceTokenBag = \"9fadf9\",\n RulesReference = \"d99993\",\n SoundCube = \"3c988f\",\n TokenArranger = \"022907\",\n TokenSource = \"124381\",\n TokenSpawnTracker = \"e3ffc9\",\n TourStarter = \"0e5aa8\",\n Trash = \"70b9f6\",\n VictoryDisplay = \"6ccd6d\"\n }\n}\n\nlocal editsToIndex = {\n White = {},\n Orange = {},\n Green = {},\n Red = {},\n Mythos = {}\n}\n\n-- save function to keep edits to the index\nfunction onSave() return JSON.encode({ editsToIndex = editsToIndex }) end\n\n-- load function to restore edits to the index\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n editsToIndex = loadedData.editsToIndex\n updateMainIndex()\n end\nend\n\n-- merges the main index and the edits\nfunction updateMainIndex()\n for owner, subTable in pairs(editsToIndex) do\n for type, guid in pairs(subTable) do\n GuidReferences[owner][type] = guid\n end\n end\nend\n\n-- returns an object reference for the requested owner and type\nfunction getObjectByOwnerAndType(params)\n local owner = params.owner or \"Mythos\"\n local type = params.type\n return getObjectFromGUID(GuidReferences[owner][type])\nend\n\n-- returns a list of objects for the requested type\nfunction getObjectsByType(type)\n local objList = {}\n for owner, objects in pairs(GuidReferences) do\n local obj = getObjectFromGUID(objects[type])\n if obj then\n objList[owner] = obj\n end\n end\n return objList\nend\n\n-- returns a list of objects for the requested owner\nfunction getObjectsByOwner(owner)\n local objList = {}\n for type, guid in pairs(GuidReferences[owner]) do\n local obj = getObjectFromGUID(guid)\n if obj then\n objList[type] = obj\n end\n end\n return objList\nend\n\n-- makes an edit to the main index\nfunction editIndex(params)\n editsToIndex[params.owner][params.type] = params.guid\n updateMainIndex()\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GUIDReferenceHandler\")\nend)\n__bundle_register(\"core/GUIDReferenceHandler\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal searchLib = require(\"util/SearchLib\")\n\nlocal GuidReferences = {\n White = {\n ClueCounter = \"d86b7c\",\n ClickableClueCounter = \"db85d6\",\n DamageCounter = \"eb08d6\",\n HandZone = \"a70eee\",\n HorrorCounter = \"468e88\",\n InvestigatorSkillTracker = \"e598c2\",\n Playermat = \"8b081b\",\n ResourceCounter = \"4406f0\",\n TokenDiscardZone = \"457de3\",\n Trash = \"147e80\"\n },\n Orange = {\n ClueCounter = \"1769ed\",\n ClickableClueCounter = \"3f22e5\",\n DamageCounter = \"e64eec\",\n HandZone = \"5fe087\",\n HorrorCounter = \"0257d9\",\n InvestigatorSkillTracker = \"b4a5f7\",\n Playermat = \"bd0ff4\",\n ResourceCounter = \"816d84\",\n TokenDiscardZone = \"457de4\",\n Trash = \"f7b6c8\"\n },\n Green = {\n ClueCounter = \"032300\",\n ClickableClueCounter = \"891403\",\n DamageCounter = \"1f5a0a\",\n HandZone = \"0285cc\",\n HorrorCounter = \"7b5729\",\n InvestigatorSkillTracker = \"af7ed7\",\n PoolResources = \"0168ae\",\n PoolDamage = \"b0ef6c\",\n PoolHorror = \"ae1a4e\",\n PoolClues = \"fae2f6\",\n PoolDoom = \"16724b\",\n Playermat = \"383d8b\",\n ResourceCounter = \"cd15ac\",\n TokenDiscardZone = \"457de5\",\n TokenRemover = \"2ba7a5\",\n Trash = \"5f896a\"\n },\n Red = {\n ClueCounter = \"37be78\",\n ClickableClueCounter = \"4111de\",\n DamageCounter = \"591a45\",\n HandZone = \"be2f17\",\n HorrorCounter = \"beb964\",\n InvestigatorSkillTracker = \"e74881\",\n PoolResources = \"fd617a\",\n PoolDamage = \"93f4a0\",\n PoolHorror = \"7bd2a0\",\n PoolClues = \"3b2550\",\n PoolDoom = \"16fcd6\",\n Playermat = \"0840d5\",\n ResourceCounter = \"a4b60d\",\n TokenDiscardZone = \"457de6\",\n TokenRemover = \"39b175\",\n Trash = \"4b8594\"\n },\n Mythos = {\n AdditionalPlayerCardsBag = \"2cba6b\",\n AllCardsBag = \"15bb07\",\n BlessCurseManager = \"5933fb\",\n CampaignThePathToCarcosa = \"aca04c\",\n ChaosBagZone = \"83ef06\",\n DataHelper = \"708279\",\n DeckImporter = \"a28140\",\n DoomCounter = \"85c4c6\",\n DoomInPlayCounter = \"652ff3\",\n InvestigatorCounter = \"f182ee\",\n MasterClueCounter = \"4a3aa4\",\n MythosArea = \"9f334f\",\n NavigationOverlayHandler = \"797ede\",\n OptionPanelSource = \"830bd0\",\n PlaceholderBoxDummy = \"a93466\",\n PlayArea = \"721ba2\",\n PlayAreaImageSelector = \"b7b45b\",\n PlayAreaZone = \"a2f932\",\n PlayerCardPanel = \"2d30ee\",\n ResourceTokenBag = \"9fadf9\",\n RulesReference = \"d99993\",\n SoundCube = \"3c988f\",\n TokenArranger = \"022907\",\n TokenSource = \"124381\",\n TokenSpawnTracker = \"e3ffc9\",\n TourStarter = \"0e5aa8\",\n Trash = \"70b9f6\",\n VictoryDisplay = \"6ccd6d\"\n }\n}\n\nlocal editsToIndex = {\n White = {},\n Orange = {},\n Green = {},\n Red = {},\n Mythos = {}\n}\n\n-- save function to keep edits to the index\nfunction onSave() return JSON.encode({ editsToIndex = editsToIndex }) end\n\n-- load function to restore edits to the index\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n editsToIndex = loadedData.editsToIndex\n updateMainIndex()\n end\nend\n\n-- merges the main index and the edits\nfunction updateMainIndex()\n for owner, subTable in pairs(editsToIndex) do\n for type, guid in pairs(subTable) do\n GuidReferences[owner][type] = guid\n end\n end\nend\n\n-- returns an object reference for the requested owner and type\nfunction getObjectByOwnerAndType(params)\n local owner = params.owner or \"Mythos\"\n local type = params.type\n return getObjectFromGUID(GuidReferences[owner][type])\nend\n\n-- returns a list of objects for the requested type\nfunction getObjectsByType(type)\n local objList = {}\n for owner, objects in pairs(GuidReferences) do\n local obj = getObjectFromGUID(objects[type])\n if obj then\n objList[owner] = obj\n end\n end\n return objList\nend\n\n-- returns a list of objects for the requested owner\nfunction getObjectsByOwner(owner)\n local objList = {}\n for type, guid in pairs(GuidReferences[owner]) do\n local obj = getObjectFromGUID(guid)\n if obj then\n objList[type] = obj\n end\n end\n return objList\nend\n\n-- makes an edit to the main index\nfunction editIndex(params)\n editsToIndex[params.owner][params.type] = params.guid\n updateMainIndex()\nend\n\n-- Returns the owner of the provided object (either the matColor or \"Mythos\")\n---@param object tts__GameObject Object to check\nfunction getOwnerOfObject(object)\n if object == nil then return end\n\n -- use GUID to check owners instead of obtaining each as reference\n local objectGuid = object.getGUID()\n\n -- check if object is directly owned\n for owner, subtable in pairs(GuidReferences) do\n for type, guid in pairs(subtable) do\n if guid == objectGuid then\n return owner\n end\n end\n end\n\n -- check if it is on an owned object\n local result = searchLib.belowPosition(object.getPosition())\n\n for owner, subtable in pairs(GuidReferences) do\n for type, guid in pairs(subtable) do\n for _, searchObj in ipairs(result) do\n if guid == searchObj.getGUID() then\n return owner\n end\n end\n end\n end\n\n -- default to \"Mythos\"\n return \"Mythos\"\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "{\"editsToIndex\":{\"Green\":[],\"Mythos\":[],\"Orange\":[],\"Red\":[],\"White\":[]}}", "MeasureMovement": false, "Name": "go_game_piece_white", @@ -625,7 +635,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/token/TokenSpawnTracker\")\nend)\n__bundle_register(\"core/token/TokenSpawnTracker\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal spawnedCardGuids = {}\n\nfunction onSave() return JSON.encode({ cards = spawnedCardGuids }) end\n\nfunction onLoad(saveState)\n if saveState ~= nil then\n local saveTable = JSON.decode(saveState) or {}\n spawnedCardGuids = saveTable.cards or {}\n end\n createResetMenuItems()\nend\n\nfunction createResetMenuItems()\n self.addContextMenuItem(\"Reset All\", resetAll)\n self.addContextMenuItem(\"Reset Locations\", resetAllLocations)\n self.addContextMenuItem(\"Reset Player Cards\", resetAllAssetAndEvents)\nend\n\nfunction hasSpawnedTokens(cardGuid)\n return spawnedCardGuids[cardGuid] == true\nend\n\nfunction markTokensSpawned(cardGuid)\n spawnedCardGuids[cardGuid] = true\nend\n\nfunction resetTokensSpawned(cardGuid)\n spawnedCardGuids[cardGuid] = nil\nend\n\nfunction resetAll() spawnedCardGuids = {} end\n\nfunction resetAllLocations() resetSpecificTypes(\"Location\") end\n\nfunction resetAllAssetAndEvents() resetSpecificTypes(\"Asset\", \"Event\") end\n\nfunction resetSpecificTypes(type1, type2)\n local resetList = {}\n for cardGuid, _ in pairs(spawnedCardGuids) do\n local card = getObjectFromGUID(cardGuid)\n if card ~= nil then\n local cardMetadata = JSON.decode(card.getGMNotes()) or {}\n -- Check this by type rather than the PlayerCard tag so we don't reset weaknesses\n if cardMetadata.type == type1 or cardMetadata.type == type2 then\n resetList[cardGuid] = true\n end\n end\n end\n for cardGuid, _ in pairs(resetList) do\n spawnedCardGuids[cardGuid] = nil\n end\nend\n\n-- Listener to reset card token spawns when they enter a hand.\nfunction onObjectEnterZone(zone, enterObject)\n if zone.type == \"Hand\" and enterObject.type == \"Card\" then\n resetTokensSpawned(enterObject.getGUID())\n end\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/token/TokenSpawnTracker\")\nend)\n__bundle_register(\"core/token/TokenSpawnTracker\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal spawnedCardGuids = {}\n\nfunction onSave() return JSON.encode({ cards = spawnedCardGuids }) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData) or {}\n spawnedCardGuids = loadedData.cards or {}\n end\n\n -- context menu entries\n self.addContextMenuItem(\"Reset All\", resetAll)\n self.addContextMenuItem(\"Reset Locations\", resetAllLocations)\n self.addContextMenuItem(\"Reset Player Cards\", resetAllAssetAndEvents)\nend\n\nfunction hasSpawnedTokens(cardGuid)\n return spawnedCardGuids[cardGuid] == true\nend\n\nfunction markTokensSpawned(cardGuid)\n spawnedCardGuids[cardGuid] = true\nend\n\nfunction resetTokensSpawned(cardGuid)\n spawnedCardGuids[cardGuid] = nil\nend\n\nfunction resetAll() spawnedCardGuids = {} end\n\nfunction resetAllLocations() resetSpecificTypes(\"Location\") end\n\nfunction resetAllAssetAndEvents() resetSpecificTypes(\"Asset\", \"Event\") end\n\nfunction resetSpecificTypes(type1, type2)\n local resetList = {}\n for cardGuid, _ in pairs(spawnedCardGuids) do\n local card = getObjectFromGUID(cardGuid)\n if card ~= nil then\n local cardMetadata = JSON.decode(card.getGMNotes()) or {}\n -- Check this by type rather than the PlayerCard tag so we don't reset weaknesses\n if cardMetadata.type == type1 or cardMetadata.type == type2 then\n resetList[cardGuid] = true\n end\n end\n end\n for cardGuid, _ in pairs(resetList) do\n spawnedCardGuids[cardGuid] = nil\n end\nend\n\n-- Listener to reset card token spawns when they enter a hand.\nfunction onObjectEnterZone(zone, enterObject)\n if zone.type == \"Hand\" and enterObject.type == \"Card\" then\n resetTokensSpawned(enterObject.getGUID())\n end\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "{\"cards\":[]}", "MeasureMovement": false, "Name": "Checker_white", @@ -1365,7 +1375,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/MythosArea\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/MythosArea\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal deckLib = require(\"util/DeckLib\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playAreaApi = require(\"core/PlayAreaApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\nlocal tokenChecker = require(\"core/token/TokenChecker\")\nlocal tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\nlocal ENCOUNTER_DECK_AREA = {\n upperLeft = { x = 0.9, z = 0.42 },\n lowerRight = { x = 0.86, z = 0.38 },\n}\nlocal ENCOUNTER_DISCARD_AREA = {\n upperLeft = { x = 1.62, z = 0.42 },\n lowerRight = { x = 1.58, z = 0.38 },\n}\n\n-- global position of encounter deck and discard pile\nlocal ENCOUNTER_DECK_POS = { x = -3.93, y = 1, z = 5.76 }\nlocal ENCOUNTER_DISCARD_POSITION = { x = -3.85, y = 1, z = 10.38 }\nlocal isReshuffling = false\nlocal collisionEnabled = false\nlocal currentScenario, useFrontData, tokenData\nlocal TRASH, DATA_HELPER\n\nfunction onLoad(saveState)\n if saveState ~= nil then\n local loadedState = JSON.decode(saveState) or {}\n currentScenario = loadedState.currentScenario or \"\"\n useFrontData = loadedState.useFrontData or true\n tokenData = loadedState.tokenData or {}\n end\n TRASH = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"Trash\")\n DATA_HELPER = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n\n Wait.time(function() collisionEnabled = true end, 0.1)\nend\n\nfunction onSave()\n return JSON.encode({\n currentScenario = currentScenario,\n useFrontData = useFrontData,\n tokenData = tokenData\n })\nend\n\n---------------------------------------------------------\n-- collison and container event handling\n---------------------------------------------------------\n\n-- TTS event handler. Handles scenario name event triggering and encounter card token resets.\nfunction onCollisionEnter(collisionInfo)\n if not collisionEnabled then return end\n\n local object = collisionInfo.collision_object\n\n -- early exit for better performance\n if object.type ~= \"Card\" then return end\n\n -- get scenario name and maybe fire followup event\n if object.getName() == \"Scenario\" then\n local description = object.getDescription()\n\n -- detect if a new scenario card is placed down\n if currentScenario ~= description then\n currentScenario = description\n fireScenarioChangedEvent()\n end\n\n local metadata = JSON.decode(object.getGMNotes()) or {}\n if not metadata[\"tokens\"] then\n tokenData = {}\n return\n end\n\n -- detect orientation of scenario card (for difficulty)\n useFrontData = not object.is_face_down\n tokenData = metadata[\"tokens\"][(useFrontData and \"front\" or \"back\")]\n fireTokenDataChangedEvent()\n end\n\n local localPos = self.positionToLocal(object.getPosition())\n if inArea(localPos, ENCOUNTER_DECK_AREA) or inArea(localPos, ENCOUNTER_DISCARD_AREA) then\n Wait.frames(function() tokenSpawnTrackerApi.resetTokensSpawned(object.getGUID()) end, 1)\n removeTokensFromObject(object)\n end\nend\n\n-- TTS event handler. Handles scenario name event triggering\nfunction onCollisionExit(collisionInfo)\n local object = collisionInfo.collision_object\n\n -- reset token metadata if scenario reference card is removed\n if object.getName() == \"Scenario\" then\n tokenData = {}\n useFrontData = nil\n fireTokenDataChangedEvent()\n end\nend\n\n-- Listens for cards entering the encounter deck or encounter discard, and resets the spawn state\n-- for the cards when they do.\nfunction onObjectEnterContainer(container, object)\n local localPos = self.positionToLocal(container.getPosition())\n if inArea(localPos, ENCOUNTER_DECK_AREA) or inArea(localPos, ENCOUNTER_DISCARD_AREA) then\n tokenSpawnTrackerApi.resetTokensSpawned(object.getGUID())\n end\nend\n\n-- fires if the scenario title changes\nfunction fireScenarioChangedEvent()\n -- maybe show the title splash screen\n Wait.frames(function() Global.call('titleSplash', currentScenario) end, 20)\n\n -- set the scenario for the playarea (connections might be disabled)\n playAreaApi.onScenarioChanged(currentScenario)\n\n -- maybe update the playarea image\n local playAreaImageSelector = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayAreaImageSelector\")\n playAreaImageSelector.call(\"maybeUpdatePlayAreaImage\", currentScenario)\nend\n\n-- fires if the scenario title or the difficulty changes\nfunction fireTokenDataChangedEvent()\n local fullData = returnTokenData()\n tokenArrangerApi.onTokenDataChanged(fullData)\nend\n\n-- returns the chaos token metadata (if provided)\nfunction returnTokenData()\n return {\n tokenData = tokenData,\n currentScenario = currentScenario,\n useFrontData = useFrontData\n }\nend\n\n---------------------------------------------------------\n-- encounter card drawing\n---------------------------------------------------------\n\n-- gets the encounter deck (for internal functions and Api calls)\nfunction getEncounterDeck()\n local searchResult = searchLib.atPosition(ENCOUNTER_DECK_POS, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n return searchResult[1]\n end\nend\n\n-- 'params' contains the position, rotation and a boolean to force a faceup draw\nfunction drawEncounterCard(params)\n local encounterDeck = getEncounterDeck()\n\n if encounterDeck then\n reshuffledAlready = false\n local card\n if encounterDeck.type == \"Deck\" then\n card = encounterDeck.takeObject()\n else\n card = encounterDeck\n end\n actualEncounterCardDraw(card, params)\n else\n -- nothing here, time to reshuffle\n if reshuffledAlready == true then\n reshuffledAlready = false\n return\n end\n reshuffleEncounterDeck() -- if there is no discard pile either, reshuffleEncounterDeck will give an error message already\n reshuffledAlready = true\n drawEncounterCard(params)\n end\nend\n\nfunction actualEncounterCardDraw(card, params)\n local faceUpRotation = 0\n if not params.alwaysFaceUp then\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.hidden or DATA_HELPER.call('checkHiddenCard', card.getName()) then\n faceUpRotation = 180\n end\n end\n\n local DRAWN_ENCOUNTER_CARD_OFFSET = {1.365, 0.5, -0.625}\n local pos = params.mat.positionToWorld(DRAWN_ENCOUNTER_CARD_OFFSET)\n local rotY = params.mat.getRotation().y\n\n deckLib.placeOrMergeIntoDeck(card, pos, { 0, rotY, faceUpRotation })\nend\n\nfunction reshuffleEncounterDeck()\n -- flag to avoid multiple calls\n if isReshuffling then return end\n isReshuffling = true\n local encounterDeck = getEncounterDeck()\n local discardPile = searchLib.atPosition(ENCOUNTER_DISCARD_POSITION, \"isCardOrDeck\")\n \n if #discardPile \u003e 0 then\n local discardDeck = discardPile[1]\n if not discardDeck.is_face_down then --flips discard pile\n discardDeck.setRotation({0, -90, 180}) \n end \n if encounterDeck == nil then\n discardDeck.setPosition(Vector(ENCOUNTER_DECK_POS) + Vector({0, 1, 0}))\n discardDeck.shuffle()\n else\n encounterDeck.putObject(discardDeck)\n encounterDeck.shuffle()\n end\n broadcastToAll(\"Shuffled encounter discard into deck.\", \"White\")\n else\n broadcastToAll(\"Encounter discard pile is already empty.\", \"Red\")\n end\n\n -- disable flag\n Wait.time(function() isReshuffling = false end, 1)\nend\n---------------------------------------------------------\n-- helper functions\n---------------------------------------------------------\n\n-- Simple method to check if the given point is in a specified area\n---@param point tts__Vector Point to check, only x and z values are relevant\n---@param bounds table Defined area to see if the point is within\n---@return boolean: True if the point is in the area defined by bounds\nfunction inArea(point, bounds)\n return (point.x \u003c bounds.upperLeft.x\n and point.x \u003e bounds.lowerRight.x\n and point.z \u003c bounds.upperLeft.z\n and point.z \u003e bounds.lowerRight.z)\nend\n\n-- removes tokens from the provided card/deck\nfunction removeTokensFromObject(object)\n for _, obj in ipairs(searchLib.onObject(object)) do\n if obj.getGUID() ~= \"4ee1f2\" and -- table\n obj ~= self and\n obj.type ~= \"Deck\" and\n obj.type ~= \"Card\" and\n obj.memo ~= nil and\n obj.getLock() == false and\n not tokenChecker.isChaosToken(obj) then\n TRASH.putObject(obj)\n end\n end\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/token/TokenChecker\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local CHAOS_TOKEN_NAMES = {\n [\"Elder Sign\"] = true,\n [\"+1\"] = true,\n [\"0\"] = true,\n [\"-1\"] = true,\n [\"-2\"] = true,\n [\"-3\"] = true,\n [\"-4\"] = true,\n [\"-5\"] = true,\n [\"-6\"] = true,\n [\"-7\"] = true,\n [\"-8\"] = true,\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n [\"Auto-fail\"] = true,\n [\"Bless\"] = true,\n [\"Curse\"] = true,\n [\"Frost\"] = true\n }\n\n local TokenChecker = {}\n\n -- returns true if the passed object is a chaos token (by name)\n TokenChecker.isChaosToken = function(obj)\n if obj.type == \"Tile\" and CHAOS_TOKEN_NAMES[obj.getName()] then\n return true\n else\n return false\n end\n end\n\n return TokenChecker\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot table New rotation for the object (optional)\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local newPos\n local offset = 0.5\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n else\n newPos = Vector(pos) + Vector(0, offset, 0)\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/MythosArea\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal deckLib = require(\"util/DeckLib\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playAreaApi = require(\"core/PlayAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\nlocal tokenChecker = require(\"core/token/TokenChecker\")\nlocal tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\nlocal ENCOUNTER_DECK_AREA = {\n upperLeft = { x = 0.9, z = 0.42 },\n lowerRight = { x = 0.86, z = 0.38 }\n}\nlocal ENCOUNTER_DISCARD_AREA = {\n upperLeft = { x = 1.62, z = 0.42 },\n lowerRight = { x = 1.58, z = 0.38 }\n}\n\n-- global position of encounter deck and discard pile\nlocal ENCOUNTER_DECK_POS = { x = -3.93, y = 1, z = 5.76 }\nlocal ENCOUNTER_DISCARD_POSITION = { x = -3.85, y = 1, z = 10.38 }\nlocal isReshuffling = false\nlocal collisionEnabled = false\nlocal currentScenario, useFrontData, tokenData\nlocal TRASH, DATA_HELPER\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedState = JSON.decode(savedData) or {}\n currentScenario = loadedState.currentScenario or \"\"\n useFrontData = loadedState.useFrontData or true\n tokenData = loadedState.tokenData or {}\n end\n TRASH = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"Trash\")\n DATA_HELPER = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n\n Wait.time(function() collisionEnabled = true end, 0.1)\nend\n\nfunction onSave()\n return JSON.encode({\n currentScenario = currentScenario,\n useFrontData = useFrontData,\n tokenData = tokenData\n })\nend\n\n---------------------------------------------------------\n-- collison and container event handling\n---------------------------------------------------------\n\n-- TTS event handler. Handles scenario name event triggering and encounter card token resets.\nfunction onCollisionEnter(collisionInfo)\n if not collisionEnabled then return end\n\n local object = collisionInfo.collision_object\n\n -- early exit for better performance\n if object.type ~= \"Card\" then return end\n\n -- get scenario name and maybe fire followup event\n if object.getName() == \"Scenario\" then\n local description = object.getDescription()\n\n -- detect if a new scenario card is placed down\n if currentScenario ~= description then\n currentScenario = description\n fireScenarioChangedEvent()\n end\n\n local metadata = JSON.decode(object.getGMNotes()) or {}\n if not metadata[\"tokens\"] then\n tokenData = {}\n return\n end\n\n -- detect orientation of scenario card (for difficulty)\n useFrontData = not object.is_face_down\n tokenData = metadata[\"tokens\"][(useFrontData and \"front\" or \"back\")]\n fireTokenDataChangedEvent()\n end\n\n local localPos = self.positionToLocal(object.getPosition())\n if inArea(localPos, ENCOUNTER_DECK_AREA) or inArea(localPos, ENCOUNTER_DISCARD_AREA) then\n Wait.frames(function() tokenSpawnTrackerApi.resetTokensSpawned(object.getGUID()) end, 1)\n removeTokensFromObject(object)\n end\nend\n\n-- TTS event handler. Handles scenario name event triggering\nfunction onCollisionExit(collisionInfo)\n local object = collisionInfo.collision_object\n\n -- reset token metadata if scenario reference card is removed\n if object.getName() == \"Scenario\" then\n tokenData = {}\n useFrontData = nil\n fireTokenDataChangedEvent()\n end\nend\n\n-- Listens for cards entering the encounter deck or encounter discard, discards tokens on them,\n-- and resets the spawn state for the cards when they do.\nfunction onObjectEnterContainer(container, object)\n local localPos = self.positionToLocal(container.getPosition())\n if inArea(localPos, ENCOUNTER_DECK_AREA) or inArea(localPos, ENCOUNTER_DISCARD_AREA) then\n tokenSpawnTrackerApi.resetTokensSpawned(object.getGUID())\n removeTokensFromObject(object)\n end\nend\n\n-- fires if the scenario title changes\nfunction fireScenarioChangedEvent()\n -- maybe show the title splash screen\n Wait.frames(function() Global.call('titleSplash', currentScenario) end, 20)\n\n -- set the scenario for the playarea (connections might be disabled)\n playAreaApi.onScenarioChanged(currentScenario)\n\n -- maybe update the playarea image\n local playAreaImageSelector = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayAreaImageSelector\")\n playAreaImageSelector.call(\"maybeUpdatePlayAreaImage\", currentScenario)\nend\n\n-- fires if the scenario title or the difficulty changes\nfunction fireTokenDataChangedEvent()\n local fullData = returnTokenData()\n tokenArrangerApi.onTokenDataChanged(fullData)\nend\n\n-- returns the chaos token metadata (if provided)\nfunction returnTokenData()\n return {\n tokenData = tokenData,\n currentScenario = currentScenario,\n useFrontData = useFrontData\n }\nend\n\n---------------------------------------------------------\n-- encounter card drawing\n---------------------------------------------------------\n\n-- gets the encounter deck (for internal functions and Api calls)\nfunction getEncounterDeck()\n local searchResult = searchLib.atPosition(ENCOUNTER_DECK_POS, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n return searchResult[1]\n end\nend\n\n-- 'params' contains the position, rotation and a boolean to force a faceup draw\nfunction drawEncounterCard(params)\n local encounterDeck = getEncounterDeck()\n local reshuffledAlready\n\n if encounterDeck then\n reshuffledAlready = false\n if encounterDeck.type == \"Deck\" then\n actualEncounterCardDraw(encounterDeck.takeObject(), params)\n else\n actualEncounterCardDraw(encounterDeck, params)\n end\n else\n -- nothing here, time to reshuffle\n if reshuffledAlready == true then\n reshuffledAlready = false\n return\n end\n\n -- if there is no discard pile either, reshuffleEncounterDeck will give an error message already\n reshuffleEncounterDeck()\n reshuffledAlready = true\n drawEncounterCard(params)\n end\nend\n\n-- draw the provided card to the requesting playmat\nfunction actualEncounterCardDraw(card, params)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n\n -- draw hidden cards facedown\n local faceUpRotation = 0\n if metadata.hidden or DATA_HELPER.call('checkHiddenCard', card.getName()) then\n faceUpRotation = 180\n end\n\n local rot = playmatApi.returnRotation(params.matColor):setAt(\"z\", faceUpRotation)\n deckLib.placeOrMergeIntoDeck(card, params.position, rot)\nend\n\nfunction reshuffleEncounterDeck()\n -- flag to avoid multiple calls\n if isReshuffling then return end\n isReshuffling = true\n\n local encounterDeck = getEncounterDeck()\n local discardPile = searchLib.atPosition(ENCOUNTER_DISCARD_POSITION, \"isCardOrDeck\")\n\n if #discardPile \u003e 0 then\n local discardDeck = discardPile[1]\n\n -- flips discard pile\n if not discardDeck.is_face_down then\n discardDeck.setRotation({ 0, -90, 180 })\n end\n\n -- make a new encounter deck\n if encounterDeck == nil then\n discardDeck.setPosition(Vector(ENCOUNTER_DECK_POS) + Vector({ 0, 1, 0 }))\n encounterDeck = discardDeck\n else\n encounterDeck.putObject(discardDeck)\n end\n encounterDeck.shuffle()\n broadcastToAll(\"Shuffled encounter discard into deck.\", \"White\")\n else\n broadcastToAll(\"Encounter discard pile is already empty.\", \"Red\")\n end\n\n -- disable flag\n Wait.time(function() isReshuffling = false end, 1)\nend\n\n---------------------------------------------------------\n-- helper functions\n---------------------------------------------------------\n\n-- Simple method to check if the given point is in a specified area\n---@param point tts__Vector Point to check, only x and z values are relevant\n---@param bounds table Defined area to see if the point is within\n---@return boolean: True if the point is in the area defined by bounds\nfunction inArea(point, bounds)\n return (point.x \u003c bounds.upperLeft.x\n and point.x \u003e bounds.lowerRight.x\n and point.z \u003c bounds.upperLeft.z\n and point.z \u003e bounds.lowerRight.z)\nend\n\n-- removes tokens from the provided card/deck\nfunction removeTokensFromObject(object)\n for _, obj in ipairs(searchLib.onObject(object)) do\n if obj.getGUID() ~= \"4ee1f2\" and -- table\n obj ~= self and\n obj.type ~= \"Deck\" and\n obj.type ~= \"Card\" and\n obj.memo ~= nil and\n obj.getLock() == false and\n not tokenChecker.isChaosToken(obj) then\n TRASH.putObject(obj)\n end\n end\nend\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/token/TokenChecker\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local CHAOS_TOKEN_NAMES = {\n [\"Elder Sign\"] = true,\n [\"+1\"] = true,\n [\"0\"] = true,\n [\"-1\"] = true,\n [\"-2\"] = true,\n [\"-3\"] = true,\n [\"-4\"] = true,\n [\"-5\"] = true,\n [\"-6\"] = true,\n [\"-7\"] = true,\n [\"-8\"] = true,\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n [\"Auto-fail\"] = true,\n [\"Bless\"] = true,\n [\"Curse\"] = true,\n [\"Frost\"] = true\n }\n\n local TokenChecker = {}\n\n -- returns true if the passed object is a chaos token (by name)\n TokenChecker.isChaosToken = function(obj)\n if obj.type == \"Tile\" and CHAOS_TOKEN_NAMES[obj.getName()] then\n return true\n else\n return false\n end\n end\n\n return TokenChecker\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/MythosArea\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot? table New rotation for the object\n ---@param below? boolean Should the object be placed below an existing deck?\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot, below)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local offset = 0.5\n local newPos = Vector(pos) + Vector(0, offset, 0)\n\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n if below then\n newPos = Vector(pos):setAt(\"y\", bounds.center.y - bounds.size.y / 2)\n else\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n end\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "{\"currentScenario\":\"\",\"tokenData\":[],\"useFrontData\":true}", "MeasureMovement": false, "Name": "Custom_Tile", @@ -2085,7 +2095,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DoomCounter\")\nend)\n__bundle_register(\"core/DoomCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playAreaApi = require(\"core/PlayAreaApi\")\nlocal searchLib = require(\"util/SearchLib\")\n\nlocal optionsVisible = false\nlocal options = {\n Agenda = true,\n Playarea = true,\n Playermats = true\n}\n\nval = 0\n\n-- save current value and options\nfunction onSave() return JSON.encode({ val, options }) end\n\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n val = loadedData[1]\n options = loadedData[2]\n\n -- restore state for option panel\n for key, bool in pairs(options) do\n self.UI.setAttribute(\"option\" .. key, \"isOn\", not bool)\n end\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = { 0, 0.06, 0 },\n height = 800,\n width = 800,\n font_size = 650,\n scale = { 1.5, 1.5, 1.5 },\n font_color = { 1, 1, 1, 95 },\n color = { 0, 0, 0, 0 }\n })\nend\n\n-- called by the invisible button to change displayed value\nfunction addOrSubtract(_, _, isRightClick)\n local newVal = math.min(math.max(val + (isRightClick and -1 or 1), 0), 99)\n if val ~= newVal then\n updateVal(newVal)\n end\nend\n\n-- adds the provided number to the current count\nfunction addVal(number)\n val = val + number\n updateVal(val)\nend\n\n-- sets the current count to the provided number\nfunction updateVal(number)\n val = number or 0\n self.editButton({ index = 0, label = tostring(val) })\n if number then\n broadcastDoom(val)\n else\n broadcastToAll(\"0 doom on the agenda\", \"White\")\n end\nend\n\n-- called by updateVal and addVal to broadcast total doom in play, including doom threshold\nfunction broadcastDoom(val)\n local doomInPlayCounter = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DoomInPlayCounter\")\n local doomInPlay = doomInPlayCounter.call(\"countDoomInPlay\") + val\n local doomThreshold = getDoomThreshold()\n\n if doomThreshold then\n broadcastToAll(val .. \" doom on the agenda (\" .. doomInPlay .. \"/\" .. doomThreshold .. \" in play)\", \"White\")\n else\n broadcastToAll(val .. \" doom on the agenda (\" .. doomInPlay .. \" in play)\", \"White\")\n end\nend\n\n-- called by \"Reset\" button to remove doom\nfunction startReset()\n if options.Agenda then\n -- omitting the number will broadcast a special message just for this case\n updateVal()\n end\n local doomInPlayCounter = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DoomInPlayCounter\")\n if doomInPlayCounter then\n doomInPlayCounter.call(\"removeDoom\", options)\n end\nend\n\n-- get doom threshold from top card of Agenda deck\nfunction getDoomThreshold()\n local agendaPos = { -2.72, 1.6, 0.37 }\n local searchResult = searchLib.atPosition(agendaPos, \"isCardOrDeck\")\n\n if #searchResult == 1 then\n local obj = searchResult[1]\n if obj.type == \"Card\" then\n return getDoomThresholdFromGMNotes(obj.getGMNotes())\n else\n -- handle agenda deck\n local containedObjects = obj.getData().ContainedObjects\n local topCardData = containedObjects[#containedObjects]\n return getDoomThresholdFromGMNotes(topCardData.GMNotes)\n end\n end\n return nil\nend\n\n-- decodes the gm notes and return the doom treshhold\nfunction getDoomThresholdFromGMNotes(notes)\n local metadata = JSON.decode(notes) or {}\n if metadata.doomThresholdPerInvestigator then\n return metadata.doomThresholdPerInvestigator * playAreaApi.getInvestigatorCount() + metadata.doomThreshold\n else\n return metadata.doomThreshold\n end\nend\n\n-- XML UI functions\nfunction optionClick(_, optionName)\n options[optionName] = not options[optionName]\n printToAll(\"Doom removal of \" .. optionName .. (options[optionName] and \" enabled\" or \" disabled\"))\nend\n\nfunction toggleOptions()\n optionsVisible = not optionsVisible\n\n if optionsVisible then\n self.UI.show(\"Options\")\n else\n self.UI.hide(\"Options\")\n end\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/DoomCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playAreaApi = require(\"core/PlayAreaApi\")\nlocal searchLib = require(\"util/SearchLib\")\n\nlocal optionsVisible = false\nlocal options = {\n Agenda = true,\n Playarea = true,\n Playermats = true\n}\n\nval = 0\n\n-- save current value and options\nfunction onSave() return JSON.encode({ val, options }) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n val = loadedData[1]\n options = loadedData[2]\n\n -- restore state for option panel\n for key, bool in pairs(options) do\n self.UI.setAttribute(\"option\" .. key, \"isOn\", not bool)\n end\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = { 0, 0.06, 0 },\n height = 800,\n width = 800,\n font_size = 650,\n scale = { 1.5, 1.5, 1.5 },\n font_color = { 1, 1, 1, 95 },\n color = { 0, 0, 0, 0 }\n })\nend\n\n-- called by the invisible button to change displayed value\nfunction addOrSubtract(_, _, isRightClick)\n local newVal = math.min(math.max(val + (isRightClick and -1 or 1), 0), 99)\n if val ~= newVal then\n updateVal(newVal)\n end\nend\n\n-- adds the provided number to the current count\nfunction addVal(number)\n val = val + number\n updateVal(val)\nend\n\n-- sets the current count to the provided number\nfunction updateVal(number)\n val = number or 0\n self.editButton({ index = 0, label = tostring(val) })\n if number then\n broadcastDoom(val)\n else\n broadcastToAll(\"0 doom on the agenda\", \"White\")\n end\nend\n\n-- called by updateVal and addVal to broadcast total doom in play, including doom threshold\nfunction broadcastDoom(val)\n local doomInPlayCounter = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DoomInPlayCounter\")\n local doomInPlay = doomInPlayCounter.call(\"countDoomInPlay\") + val\n local doomThreshold = getDoomThreshold()\n\n if doomThreshold then\n broadcastToAll(val .. \" doom on the agenda (\" .. doomInPlay .. \"/\" .. doomThreshold .. \" in play)\", \"White\")\n else\n broadcastToAll(val .. \" doom on the agenda (\" .. doomInPlay .. \" in play)\", \"White\")\n end\nend\n\n-- called by \"Reset\" button to remove doom\nfunction startReset()\n if options.Agenda then\n -- omitting the number will broadcast a special message just for this case\n updateVal()\n end\n local doomInPlayCounter = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DoomInPlayCounter\")\n if doomInPlayCounter then\n doomInPlayCounter.call(\"removeDoom\", options)\n end\nend\n\n-- get doom threshold from top card of Agenda deck\nfunction getDoomThreshold()\n local agendaPos = { -2.72, 1.6, 0.37 }\n local searchResult = searchLib.atPosition(agendaPos, \"isCardOrDeck\")\n\n if #searchResult == 1 then\n local obj = searchResult[1]\n if obj.type == \"Card\" then\n return getDoomThresholdFromGMNotes(obj.getGMNotes())\n else\n -- handle agenda deck\n local containedObjects = obj.getData().ContainedObjects\n local topCardData = containedObjects[#containedObjects]\n return getDoomThresholdFromGMNotes(topCardData.GMNotes)\n end\n end\n return nil\nend\n\n-- decodes the gm notes and return the doom treshhold\nfunction getDoomThresholdFromGMNotes(notes)\n local metadata = JSON.decode(notes) or {}\n if metadata.doomThresholdPerInvestigator then\n return metadata.doomThresholdPerInvestigator * playAreaApi.getInvestigatorCount() + metadata.doomThreshold\n else\n return metadata.doomThreshold\n end\nend\n\n-- XML UI functions\nfunction optionClick(_, optionName)\n options[optionName] = not options[optionName]\n printToAll(\"Doom removal of \" .. optionName .. (options[optionName] and \" enabled\" or \" disabled\"))\nend\n\nfunction toggleOptions()\n optionsVisible = not optionsVisible\n\n if optionsVisible then\n self.UI.show(\"Options\")\n else\n self.UI.hide(\"Options\")\n end\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DoomCounter\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[0,{\"Agenda\":true,\"Playarea\":true,\"Playermats\":true}]", "MeasureMovement": false, "Name": "Custom_Token", @@ -2259,7 +2269,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/ActiveInvestigatorCounter\")\nend)\n__bundle_register(\"core/ActiveInvestigatorCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nMIN_VALUE = 1\nMAX_VALUE = 4\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/ActiveInvestigatorCounter\")\nend)\n__bundle_register(\"core/ActiveInvestigatorCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nMIN_VALUE = 1\nMAX_VALUE = 4\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "2", "MeasureMovement": false, "Name": "Custom_Token", @@ -2437,7 +2447,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "0", "MeasureMovement": false, "Name": "Custom_Token", @@ -2497,7 +2507,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "0", "MeasureMovement": false, "Name": "Custom_Token", @@ -2557,7 +2567,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "0", "MeasureMovement": false, "Name": "Custom_Token", @@ -2617,7 +2627,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "0", "MeasureMovement": false, "Name": "Custom_Token", @@ -2677,7 +2687,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "5", "MeasureMovement": false, "Name": "Custom_Token", @@ -2734,7 +2744,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "0", "MeasureMovement": false, "Name": "Custom_Token", @@ -2791,7 +2801,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "0", "MeasureMovement": false, "Name": "Custom_Token", @@ -2848,7 +2858,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "0", "MeasureMovement": false, "Name": "Custom_Token", @@ -2905,7 +2915,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "0", "MeasureMovement": false, "Name": "Custom_Token", @@ -2962,7 +2972,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "5", "MeasureMovement": false, "Name": "Custom_Token", @@ -3019,7 +3029,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "0", "MeasureMovement": false, "Name": "Custom_Token", @@ -3076,7 +3086,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "0", "MeasureMovement": false, "Name": "Custom_Token", @@ -3133,7 +3143,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "5", "MeasureMovement": false, "Name": "Custom_Token", @@ -3190,7 +3200,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "0", "MeasureMovement": false, "Name": "Custom_Token", @@ -3247,7 +3257,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "0", "MeasureMovement": false, "Name": "Custom_Token", @@ -3304,7 +3314,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "5", "MeasureMovement": false, "Name": "Custom_Token", @@ -3398,8 +3408,8 @@ }, { "AltLookAngle": { - "x": 0, - "y": 0, + "x": 180, + "y": 180, "z": 0 }, "Autoraise": true, @@ -3439,7 +3449,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "function onLoad()\n self.addContextMenuItem(\"Download\", download)\nend\n\nfunction download()\n Global.call('placeholder_download', { url = self.getGMNotes(), replace = self.guid })\nend", + "LuaScript": "function onLoad()\n self.addContextMenuItem(\"Download\", download)\nend\n\nfunction download(playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -18833,7 +18843,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/ClueCounter\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/ClueCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\n\nexposedValue = 0\n\nlocal playmat\nlocal searchParam = {}\n\nfunction onLoad()\n self.createButton({\n label = \"\",\n click_function = \"countItems\",\n function_owner = self,\n position = { 0, 0.1, 0 },\n height = 0,\n width = 0,\n font_color = { 0, 0, 0 },\n font_size = 2000\n })\n\n -- get closest playmat\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n playmat = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\")\n\n -- get search parameters (threat area excluded)\n local localPos = playmat.positionToLocal(playmat.getPosition())\n searchParam.pos = playmat.positionToWorld(localPos + Vector(0, 0, 0.4))\n searchParam.rot = playmat.getRotation() + Vector(0, 90, 0)\n searchParam.size = Vector(8, 1, 27)\n searchParam.filter = \"isClue\"\n\n -- start loop\n Wait.time(countItems, 1.5, -1)\nend\n\n-- activated once per second, counts clues on the playmat\nfunction countItems()\n local totalValue = 0\n for _, item in ipairs(getClues()) do\n totalValue = totalValue + math.abs(item.getQuantity())\n end\n exposedValue = totalValue\n self.editButton({ index = 0, label = totalValue })\nend\n\nfunction removeAllClues(trash)\n for _, obj in ipairs(getClues()) do\n trash.putObject(obj)\n end\nend\n\nfunction getClues()\n return searchLib.inArea(searchParam.pos, searchParam.rot, searchParam.size, searchParam.filter)\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/ClueCounter\")\nend)\n__bundle_register(\"playermat/ClueCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\n\nexposedValue = 0\n\nlocal playmat\nlocal searchParam = {}\n\nfunction onLoad()\n self.createButton({\n label = \"\",\n click_function = \"countItems\",\n function_owner = self,\n position = { 0, 0.1, 0 },\n height = 0,\n width = 0,\n font_color = { 0, 0, 0 },\n font_size = 2000\n })\n\n -- get closest playmat\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n playmat = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\")\n\n -- get search parameters (threat area excluded)\n local localPos = playmat.positionToLocal(playmat.getPosition())\n searchParam.pos = playmat.positionToWorld(localPos + Vector(0, 0, 0.4))\n searchParam.rot = playmat.getRotation() + Vector(0, 90, 0)\n searchParam.size = Vector(8, 1, 27)\n searchParam.filter = \"isClue\"\n\n -- start loop\n Wait.time(countItems, 1.5, -1)\nend\n\n-- activated once per second, counts clues on the playmat\nfunction countItems()\n local totalValue = 0\n for _, item in ipairs(getClues()) do\n totalValue = totalValue + math.abs(item.getQuantity())\n end\n exposedValue = totalValue\n self.editButton({ index = 0, label = totalValue })\nend\n\nfunction removeAllClues(trash)\n for _, obj in ipairs(getClues()) do\n trash.putObject(obj)\n end\nend\n\nfunction getClues()\n return searchLib.inArea(searchParam.pos, searchParam.rot, searchParam.size, searchParam.filter)\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -18899,7 +18909,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/ClueCounter\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/ClueCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\n\nexposedValue = 0\n\nlocal playmat\nlocal searchParam = {}\n\nfunction onLoad()\n self.createButton({\n label = \"\",\n click_function = \"countItems\",\n function_owner = self,\n position = { 0, 0.1, 0 },\n height = 0,\n width = 0,\n font_color = { 0, 0, 0 },\n font_size = 2000\n })\n\n -- get closest playmat\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n playmat = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\")\n\n -- get search parameters (threat area excluded)\n local localPos = playmat.positionToLocal(playmat.getPosition())\n searchParam.pos = playmat.positionToWorld(localPos + Vector(0, 0, 0.4))\n searchParam.rot = playmat.getRotation() + Vector(0, 90, 0)\n searchParam.size = Vector(8, 1, 27)\n searchParam.filter = \"isClue\"\n\n -- start loop\n Wait.time(countItems, 1.5, -1)\nend\n\n-- activated once per second, counts clues on the playmat\nfunction countItems()\n local totalValue = 0\n for _, item in ipairs(getClues()) do\n totalValue = totalValue + math.abs(item.getQuantity())\n end\n exposedValue = totalValue\n self.editButton({ index = 0, label = totalValue })\nend\n\nfunction removeAllClues(trash)\n for _, obj in ipairs(getClues()) do\n trash.putObject(obj)\n end\nend\n\nfunction getClues()\n return searchLib.inArea(searchParam.pos, searchParam.rot, searchParam.size, searchParam.filter)\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playermat/ClueCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\n\nexposedValue = 0\n\nlocal playmat\nlocal searchParam = {}\n\nfunction onLoad()\n self.createButton({\n label = \"\",\n click_function = \"countItems\",\n function_owner = self,\n position = { 0, 0.1, 0 },\n height = 0,\n width = 0,\n font_color = { 0, 0, 0 },\n font_size = 2000\n })\n\n -- get closest playmat\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n playmat = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\")\n\n -- get search parameters (threat area excluded)\n local localPos = playmat.positionToLocal(playmat.getPosition())\n searchParam.pos = playmat.positionToWorld(localPos + Vector(0, 0, 0.4))\n searchParam.rot = playmat.getRotation() + Vector(0, 90, 0)\n searchParam.size = Vector(8, 1, 27)\n searchParam.filter = \"isClue\"\n\n -- start loop\n Wait.time(countItems, 1.5, -1)\nend\n\n-- activated once per second, counts clues on the playmat\nfunction countItems()\n local totalValue = 0\n for _, item in ipairs(getClues()) do\n totalValue = totalValue + math.abs(item.getQuantity())\n end\n exposedValue = totalValue\n self.editButton({ index = 0, label = totalValue })\nend\n\nfunction removeAllClues(trash)\n for _, obj in ipairs(getClues()) do\n trash.putObject(obj)\n end\nend\n\nfunction getClues()\n return searchLib.inArea(searchParam.pos, searchParam.rot, searchParam.size, searchParam.filter)\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/ClueCounter\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -18965,7 +18975,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/ClueCounter\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/ClueCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\n\nexposedValue = 0\n\nlocal playmat\nlocal searchParam = {}\n\nfunction onLoad()\n self.createButton({\n label = \"\",\n click_function = \"countItems\",\n function_owner = self,\n position = { 0, 0.1, 0 },\n height = 0,\n width = 0,\n font_color = { 0, 0, 0 },\n font_size = 2000\n })\n\n -- get closest playmat\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n playmat = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\")\n\n -- get search parameters (threat area excluded)\n local localPos = playmat.positionToLocal(playmat.getPosition())\n searchParam.pos = playmat.positionToWorld(localPos + Vector(0, 0, 0.4))\n searchParam.rot = playmat.getRotation() + Vector(0, 90, 0)\n searchParam.size = Vector(8, 1, 27)\n searchParam.filter = \"isClue\"\n\n -- start loop\n Wait.time(countItems, 1.5, -1)\nend\n\n-- activated once per second, counts clues on the playmat\nfunction countItems()\n local totalValue = 0\n for _, item in ipairs(getClues()) do\n totalValue = totalValue + math.abs(item.getQuantity())\n end\n exposedValue = totalValue\n self.editButton({ index = 0, label = totalValue })\nend\n\nfunction removeAllClues(trash)\n for _, obj in ipairs(getClues()) do\n trash.putObject(obj)\n end\nend\n\nfunction getClues()\n return searchLib.inArea(searchParam.pos, searchParam.rot, searchParam.size, searchParam.filter)\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playermat/ClueCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\n\nexposedValue = 0\n\nlocal playmat\nlocal searchParam = {}\n\nfunction onLoad()\n self.createButton({\n label = \"\",\n click_function = \"countItems\",\n function_owner = self,\n position = { 0, 0.1, 0 },\n height = 0,\n width = 0,\n font_color = { 0, 0, 0 },\n font_size = 2000\n })\n\n -- get closest playmat\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n playmat = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\")\n\n -- get search parameters (threat area excluded)\n local localPos = playmat.positionToLocal(playmat.getPosition())\n searchParam.pos = playmat.positionToWorld(localPos + Vector(0, 0, 0.4))\n searchParam.rot = playmat.getRotation() + Vector(0, 90, 0)\n searchParam.size = Vector(8, 1, 27)\n searchParam.filter = \"isClue\"\n\n -- start loop\n Wait.time(countItems, 1.5, -1)\nend\n\n-- activated once per second, counts clues on the playmat\nfunction countItems()\n local totalValue = 0\n for _, item in ipairs(getClues()) do\n totalValue = totalValue + math.abs(item.getQuantity())\n end\n exposedValue = totalValue\n self.editButton({ index = 0, label = totalValue })\nend\n\nfunction removeAllClues(trash)\n for _, obj in ipairs(getClues()) do\n trash.putObject(obj)\n end\nend\n\nfunction getClues()\n return searchLib.inArea(searchParam.pos, searchParam.rot, searchParam.size, searchParam.filter)\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/ClueCounter\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -19031,7 +19041,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/ClueCounter\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/ClueCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\n\nexposedValue = 0\n\nlocal playmat\nlocal searchParam = {}\n\nfunction onLoad()\n self.createButton({\n label = \"\",\n click_function = \"countItems\",\n function_owner = self,\n position = { 0, 0.1, 0 },\n height = 0,\n width = 0,\n font_color = { 0, 0, 0 },\n font_size = 2000\n })\n\n -- get closest playmat\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n playmat = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\")\n\n -- get search parameters (threat area excluded)\n local localPos = playmat.positionToLocal(playmat.getPosition())\n searchParam.pos = playmat.positionToWorld(localPos + Vector(0, 0, 0.4))\n searchParam.rot = playmat.getRotation() + Vector(0, 90, 0)\n searchParam.size = Vector(8, 1, 27)\n searchParam.filter = \"isClue\"\n\n -- start loop\n Wait.time(countItems, 1.5, -1)\nend\n\n-- activated once per second, counts clues on the playmat\nfunction countItems()\n local totalValue = 0\n for _, item in ipairs(getClues()) do\n totalValue = totalValue + math.abs(item.getQuantity())\n end\n exposedValue = totalValue\n self.editButton({ index = 0, label = totalValue })\nend\n\nfunction removeAllClues(trash)\n for _, obj in ipairs(getClues()) do\n trash.putObject(obj)\n end\nend\n\nfunction getClues()\n return searchLib.inArea(searchParam.pos, searchParam.rot, searchParam.size, searchParam.filter)\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/ClueCounter\")\nend)\n__bundle_register(\"playermat/ClueCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\n\nexposedValue = 0\n\nlocal playmat\nlocal searchParam = {}\n\nfunction onLoad()\n self.createButton({\n label = \"\",\n click_function = \"countItems\",\n function_owner = self,\n position = { 0, 0.1, 0 },\n height = 0,\n width = 0,\n font_color = { 0, 0, 0 },\n font_size = 2000\n })\n\n -- get closest playmat\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n playmat = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\")\n\n -- get search parameters (threat area excluded)\n local localPos = playmat.positionToLocal(playmat.getPosition())\n searchParam.pos = playmat.positionToWorld(localPos + Vector(0, 0, 0.4))\n searchParam.rot = playmat.getRotation() + Vector(0, 90, 0)\n searchParam.size = Vector(8, 1, 27)\n searchParam.filter = \"isClue\"\n\n -- start loop\n Wait.time(countItems, 1.5, -1)\nend\n\n-- activated once per second, counts clues on the playmat\nfunction countItems()\n local totalValue = 0\n for _, item in ipairs(getClues()) do\n totalValue = totalValue + math.abs(item.getQuantity())\n end\n exposedValue = totalValue\n self.editButton({ index = 0, label = totalValue })\nend\n\nfunction removeAllClues(trash)\n for _, obj in ipairs(getClues()) do\n trash.putObject(obj)\n end\nend\n\nfunction getClues()\n return searchLib.inArea(searchParam.pos, searchParam.rot, searchParam.size, searchParam.filter)\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -19088,7 +19098,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/MasterClueCounter\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/MasterClueCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- variables are intentionally global to be accessible\ncount = 0\nuseClickableCounters = false\n\nfunction onSave() return JSON.encode(useClickableCounters) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n useClickableCounters = JSON.decode(savedData)\n end\n self.createButton({\n label = \"0\",\n click_function = \"removeAllPlayerClues\",\n tooltip = \"Click here to remove all collected clues\",\n function_owner = self,\n position = { 0, 0.06, 0 },\n height = 900,\n width = 900,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 650,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n Wait.time(sumClues, 2, -1)\nend\n\n-- removes all player clues by calling the respective function from the counting bowls / clickers\nfunction removeAllPlayerClues()\n printToAll(count .. \" clue(s) from playermats removed.\", \"White\")\n playmatApi.removeClues(\"All\")\n self.editButton({ index = 0, label = \"0\" })\nend\n\n-- gets the counted values from the counting bowls / clickers and sums them up\nfunction sumClues()\n count = playmatApi.getClueCount(useClickableCounters, \"All\")\n self.editButton({ index = 0, label = tostring(count) })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/MasterClueCounter\")\nend)\n__bundle_register(\"core/MasterClueCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- variables are intentionally global to be accessible\ncount = 0\nuseClickableCounters = false\n\nfunction onSave() return JSON.encode(useClickableCounters) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n useClickableCounters = JSON.decode(savedData)\n end\n\n self.createButton({\n label = \"0\",\n click_function = \"removeAllPlayerClues\",\n tooltip = \"Click here to remove all collected clues\",\n function_owner = self,\n position = { 0, 0.06, 0 },\n height = 900,\n width = 900,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 650,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n Wait.time(sumClues, 2, -1)\nend\n\n-- removes all player clues by calling the respective function from the counting bowls / clickers\nfunction removeAllPlayerClues()\n printToAll(count .. \" clue(s) from playermats removed.\", \"White\")\n playmatApi.removeClues(\"All\")\n self.editButton({ index = 0, label = \"0\" })\nend\n\n-- gets the counted values from the counting bowls / clickers and sums them up\nfunction sumClues()\n count = playmatApi.getClueCount(useClickableCounters, \"All\")\n self.editButton({ index = 0, label = tostring(count) })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "false", "MeasureMovement": false, "Name": "Custom_Token", @@ -20379,7 +20389,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/PlayArea\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/PlayArea\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenManager = require(\"core/token/TokenManager\")\n\n-- Location connection directional options\nlocal BIDIRECTIONAL = 0\nlocal ONE_WAY = 1\nlocal INCOMING_ONE_WAY = 2\n\n-- Connector draw parameters\nlocal CONNECTION_THICKNESS = 0.015\nlocal DRAGGING_CONNECTION_THICKNESS = 0.15\nlocal DRAGGING_CONNECTION_COLOR = { 0.8, 0.8, 0.8, 1 }\nlocal DIRECTIONAL_ARROW_DISTANCE = 3.5\nlocal ARROW_ARM_LENGTH = 0.9\nlocal ARROW_ANGLE = 25\n\n-- Height to draw the connector lines, places them just above the table and always below cards\nlocal CONNECTION_LINE_Y = 1.529\n\n-- used for recreating the link to a custom data helper after image change\ncustomDataHelper = nil\n\nlocal DEFAULT_URL = \"http://cloud-3.steamusercontent.com/ugc/998015670465071049/FFAE162920D67CF38045EFBD3B85AD0F916147B2/\"\n\nlocal SHIFT_OFFSETS = {\n left = { x = 0.00, y = 0, z = 7.67 },\n right = { x = 0.00, y = 0, z = -7.67 },\n up = { x = 6.54, y = 0, z = 0.00 },\n down = { x = -6.54, y = 0, z = 0.00 }\n}\nlocal SHIFT_EXCLUSION = {\n [\"b7b45b\"] = true,\n [\"f182ee\"] = true,\n [\"721ba2\"] = true\n}\nlocal LOC_LINK_EXCLUDE_SCENARIOS = {\n [\"The Witching Hour\"] = true,\n [\"The Heart of Madness\"] = true\n}\n\nlocal locations = {}\nlocal locationConnections = {}\nlocal draggingGuids = {}\nlocal missingData = {}\nlocal collisionEnabled = false\nlocal currentScenario, connectionsEnabled\n\n---------------------------------------------------------\n-- general code\n---------------------------------------------------------\n\nfunction onSave()\n return JSON.encode({\n trackedLocations = locations,\n currentScenario = currentScenario,\n connectionColor = connectionColor,\n connectionsEnabled = connectionsEnabled\n })\nend\n\nfunction onLoad(savedData)\n self.interactable = false -- this needs to be here since the playarea will be reloaded when the image changes\n local loadedData = JSON.decode(savedData) or {}\n locations = loadedData.trackedLocations or {}\n currentScenario = loadedData.currentScenario\n connectionColor = loadedData.connectionColor or { 0.4, 0.4, 0.4, 1 }\n connectionsEnabled = loadedData.connectionsEnabled or true\n\n Wait.time(function() collisionEnabled = true end, 0.1)\nend\n\n-- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n-- data to the local token manager instance.\n---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\nfunction updateLocations(args)\n customDataHelper = getObjectFromGUID(args[1])\n if customDataHelper ~= nil then\n tokenManager.addLocationData(customDataHelper.getTable(\"LOCATIONS_DATA\"))\n end\nend\n\n-- sets the image of the playarea\nfunction updateSurface(newURL)\n local customInfo = self.getCustomObject()\n\n if newURL ~= \"\" and newURL ~= nil and newURL ~= DEFAULT_URL then\n customInfo.image = newURL\n broadcastToAll(\"New Playarea Image Applied\", \"Green\")\n else\n customInfo.image = DEFAULT_URL\n broadcastToAll(\"Default Playarea Image Applied\", \"Green\")\n end\n\n self.setCustomObject(customInfo)\n\n local guid = nil\n\n if customDataHelper then guid = customDataHelper.getGUID() end\n self.reload()\n\n if guid ~= nil then\n Wait.time(function() updateLocations({ guid }) end, 1)\n end\nend\n\n-- TTS event, called for each object that is placed on the playarea\nfunction onCollisionEnter(collisionInfo)\n if not collisionEnabled then return end\n\n local object = collisionInfo.collision_object\n\n if object.type == \"Deck\" then\n table.insert(missingData, object)\n end\n\n -- only continue for cards\n if object.type ~= \"Card\" then return end\n\n -- check if we should spawn clues here and do so according to playercount\n if shouldSpawnTokens(object) then\n tokenManager.spawnForCard(object)\n end\n\n -- If this card was being dragged, clear the dragging connections. A multi-drag/drop may send\n -- the dropped card immediately into a deck, so this has to be done here\n if draggingGuids[object.getGUID()] ~= nil then\n object.setVectorLines({})\n draggingGuids[object.getGUID()] = nil\n end\n\n maybeTrackLocation(object)\nend\n\nfunction shouldSpawnTokens(card)\n local metadata = JSON.decode(card.getGMNotes())\n if metadata == nil then\n return tokenManager.hasLocationData(card)\n end\n return metadata.type == \"Location\"\n or metadata.type == \"Enemy\"\n or metadata.type == \"Treachery\"\n or metadata.weakness\n -- hardcoded IDs for \"Makeshift Trap\" and \"Shrine of the Moirai\"\n -- these cards are events with uses, that attach to encounter cards and thus will enter play in the playarea\n -- TODO: probably turn this into a metadata field if we get more cards like that\n or metadata.id == \"07310\"\n or metadata.id == \"09100\"\nend\n\nfunction onCollisionExit(collisionInfo)\n maybeUntrackLocation(collisionInfo.collision_object)\nend\n\n-- Destroyed objects don't trigger onCollisionExit(), so check on destruction to untrack as well\nfunction onObjectDestroy(object)\n maybeUntrackLocation(object)\nend\n\nfunction onObjectPickUp(player, object)\n -- only continue for cards\n local objType = object.name\n if objType ~= \"Card\" and objType ~= \"CardCustom\" then return end\n\n -- onCollisionExit USUALLY fires first, so we have to check the card to see if it's a location we\n -- should be tracking\n if showLocationLinks() and isInPlayArea(object) and object.getGMNotes() ~= nil and object.getGMNotes() ~= \"\" then\n local pickedUpGuid = object.getGUID()\n local metadata = JSON.decode(object.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n -- onCollisionExit sometimes comes 1 frame after onObjectPickUp (rather than before it or in\n -- the same frame). This causes a mismatch in the data between dragging the on-table, and\n -- that one frame draws connectors on the card which then show up as shadows for snap points.\n -- Waiting ensures we always do thing in the expected Exit-\u003ePickUp order\n Wait.frames(function()\n if object.is_face_down then\n draggingGuids[pickedUpGuid] = metadata.locationBack\n else\n draggingGuids[pickedUpGuid] = metadata.locationFront\n end\n rebuildConnectionList()\n end, 2)\n end\n end\nend\n\nfunction onUpdate()\n -- Due to the frequence of onUpdate calls, ensure that we only process any changes to the\n -- connection list once, and only redraw once\n local needsConnectionRebuild = false\n local needsConnectionDraw = false\n for guid, _ in pairs(draggingGuids) do\n local obj = getObjectFromGUID(guid)\n if obj == nil or not isInPlayArea(obj) then\n draggingGuids[guid] = nil\n needsConnectionRebuild = true\n -- If object still exists then it's been dragged outside the area and needs to clear the\n -- lines attached to it\n if obj ~= nil then\n obj.setVectorLines({})\n end\n end\n -- Even if the last location left the play area, need one last draw to clear the lines\n needsConnectionDraw = true\n end\n if needsConnectionRebuild then\n rebuildConnectionList()\n end\n if needsConnectionDraw then\n drawDraggingConnections()\n end\nend\n\n-- Checks the given card and adds it to the list of locations tracked for connection purposes.\n-- A card will be added to the tracking if it is a location in the play area (based on centerpoint).\n---@param card tts__Object A card object, possibly a location.\nfunction maybeTrackLocation(card)\n -- Collision checks for any part of the card overlap, but our other tracking is centerpoint\n -- Ignore any collision where the centerpoint isn't in the area\n if isInPlayArea(card) then\n local metadata = JSON.decode(card.getGMNotes())\n if metadata == nil then\n table.insert(missingData, card)\n else\n if metadata.type == \"Location\" then\n if card.is_face_down then\n locations[card.getGUID()] = metadata.locationBack\n else\n locations[card.getGUID()] = metadata.locationFront\n end\n\n -- only draw connection lines for not-excluded scenarios\n if showLocationLinks() then\n rebuildConnectionList()\n drawBaseConnections()\n end\n end\n end\n end\nend\n\n-- Stop tracking a location for connection drawing. This should be called for both collision exit\n-- and destruction, as a destroyed object does not trigger collision exit. An object can also be\n-- deleted mid-drag, but the ordering for drag events means we can't clear those here and those will\n-- be cleared in the next onUpdate() cycle.\n---@param card tts__Object Card to (maybe) stop tracking\nfunction maybeUntrackLocation(card)\n -- Locked objects no longer collide (hence triggering an exit event) but are still in the play\n -- area. If the object is now locked, don't remove it.\n if locations[card.getGUID()] ~= nil and not card.locked then\n locations[card.getGUID()] = nil\n rebuildConnectionList()\n drawBaseConnections()\n end\nend\n\n-- Global event handler, delegated from Global. Clears any connection lines from dragged cards\n-- before they are destroyed by entering a deck. Removal of the card from the dragging list will\n-- be handled during the next onUpdate() call.\nfunction tryObjectEnterContainer()\n for draggedGuid, _ in pairs(draggingGuids) do\n local draggedObj = getObjectFromGUID(draggedGuid)\n if draggedObj ~= nil then\n draggedObj.setVectorLines({})\n end\n end\nend\n\n-- Builds a list of GUID to GUID connection information based on the currently tracked locations.\n-- This will update the connection information and store it in the locationConnections data member,\n-- but does not draw those connections. This should often be followed by a call to\n-- drawBaseConnections()\nfunction rebuildConnectionList()\n if not showLocationLinks() then\n locationConnections = {}\n return\n end\n\n local iconCardList = {}\n\n -- Build a list of cards with each icon as their location ID\n for cardId, metadata in pairs(draggingGuids) do\n buildLocListByIcon(cardId, iconCardList, metadata)\n end\n for cardId, metadata in pairs(locations) do\n buildLocListByIcon(cardId, iconCardList, metadata)\n end\n\n -- Pair up all the icons\n locationConnections = {}\n for cardId, metadata in pairs(draggingGuids) do\n buildConnection(cardId, iconCardList, metadata)\n end\n for cardId, metadata in pairs(locations) do\n if draggingGuids[cardId] == nil then\n buildConnection(cardId, iconCardList, metadata)\n end\n end\nend\n\n-- Extracts the card's icon string into a list of individual location icons\n---@param cardId string GUID of the card to pull the icon data from\n---@param iconCardList table A table of icon-\u003eGUID list. Mutable, will be updated by this method\n---@param locData table A table containing the metadata for the card (for the correct side)\nfunction buildLocListByIcon(cardId, iconCardList, locData)\n if locData ~= nil and locData.icons ~= nil then\n for icon in string.gmatch(locData.icons, \"%a+\") do\n if iconCardList[icon] == nil then\n iconCardList[icon] = {}\n end\n table.insert(iconCardList[icon], cardId)\n end\n end\nend\n\n-- Builds the connections for the given cardID by finding matching icons and adding them to the\n-- Playarea's locationConnections table.\n---@param cardId string GUID of the card to build the connections for\n---@param iconCardList table A table of icon-\u003eGUID List. Used to find matching icons for connections.\n---@param locData table A table containing the metadata for the card (for the correct side)\nfunction buildConnection(cardId, iconCardList, locData)\n if locData ~= nil and locData.connections ~= nil then\n locationConnections[cardId] = {}\n for icon in string.gmatch(locData.connections, \"%a+\") do\n if iconCardList[icon] ~= nil then\n for _, connectedGuid in ipairs(iconCardList[icon]) do\n -- If the reciprocal exists, convert it to BiDi, otherwise add as a one-way\n if locationConnections[connectedGuid] ~= nil\n and (locationConnections[connectedGuid][cardId] == ONE_WAY\n or locationConnections[connectedGuid][cardId] == BIDIRECTIONAL) then\n locationConnections[connectedGuid][cardId] = BIDIRECTIONAL\n locationConnections[cardId][connectedGuid] = nil\n else\n if locationConnections[connectedGuid] == nil then\n locationConnections[connectedGuid] = {}\n end\n locationConnections[cardId][connectedGuid] = ONE_WAY\n locationConnections[connectedGuid][cardId] = INCOMING_ONE_WAY\n end\n end\n end\n end\n end\nend\n\n-- Draws the lines for connections currently in locationConnections but not in draggingGuids.\n-- Constructed vectors will be set to the playmat\nfunction drawBaseConnections()\n if not showLocationLinks() then\n locationConnections = {}\n self.setVectorLines({})\n return\n end\n local cardConnectionLines = {}\n\n for originGuid, targetGuids in pairs(locationConnections) do\n -- Objects should reliably exist at this point, but since this can be called during onUpdate the\n -- object checks are conservative just to make sure.\n local origin = getObjectFromGUID(originGuid)\n if draggingGuids[originGuid] == nil and origin ~= nil then\n for targetGuid, direction in pairs(targetGuids) do\n local target = getObjectFromGUID(targetGuid)\n if draggingGuids[targetGuid] == nil and target ~= nil then\n -- Since we process the full list, we're guaranteed to hit any ONE_WAY connections later\n -- so we can ignore INCOMING_ONE_WAY\n if direction == BIDIRECTIONAL then\n addBidirectionalVector(origin, target, self, cardConnectionLines)\n elseif direction == ONE_WAY then\n addOneWayVector(origin, target, self, cardConnectionLines)\n end\n end\n end\n end\n end\n self.setVectorLines(cardConnectionLines)\nend\n\n-- Draws the lines for cards which are currently being dragged.\nfunction drawDraggingConnections()\n if not showLocationLinks() then\n return\n end\n local cardConnectionLines = {}\n local ownedVectors = {}\n\n for originGuid, _ in pairs(draggingGuids) do\n targetGuids = locationConnections[originGuid]\n -- Objects should reliably exist at this point, but since this can be called during onUpdate the\n -- object checks are conservative just to make sure.\n local origin = getObjectFromGUID(originGuid)\n if draggingGuids[originGuid] and origin ~= nil and targetGuids ~= nil then\n ownedVectors[originGuid] = {}\n for targetGuid, direction in pairs(targetGuids) do\n local target = getObjectFromGUID(targetGuid)\n if target ~= nil then\n if direction == BIDIRECTIONAL then\n addBidirectionalVector(origin, target, origin, ownedVectors[originGuid])\n elseif direction == ONE_WAY then\n addOneWayVector(origin, target, origin, ownedVectors[originGuid])\n elseif direction == INCOMING_ONE_WAY and not draggingGuids[targetGuid] then\n addOneWayVector(target, origin, origin, ownedVectors[originGuid])\n end\n end\n end\n end\n end\n for ownerGuid, vectors in pairs(ownedVectors) do\n local card = getObjectFromGUID(ownerGuid)\n card.setVectorLines(vectors)\n end\nend\n\n-- Draws a bidirectional location connection between the two cards, adding the lines to do so to the\n-- given lines list.\n---@param card1 tts__Object One of the card objects to connect\n---@param card2 tts__Object The other card object to connect\n---@param vectorOwner tts__Object The object which these lines will be set to. Used for relative\n--- positioning and scaling, as well as highlighting connections during a drag operation\n---@param lines table List of vector line elements. Mutable, will be updated to add this connector\nfunction addBidirectionalVector(card1, card2, vectorOwner, lines)\n local cardPos1 = card1.getPosition()\n local cardPos2 = card2.getPosition()\n cardPos1.y = CONNECTION_LINE_Y\n cardPos2.y = CONNECTION_LINE_Y\n\n local pos1 = vectorOwner.positionToLocal(cardPos1)\n local pos2 = vectorOwner.positionToLocal(cardPos2)\n\n table.insert(lines, {\n points = { pos1, pos2 },\n color = vectorOwner == self and connectionColor or DRAGGING_CONNECTION_COLOR,\n thickness = vectorOwner == self and CONNECTION_THICKNESS or DRAGGING_CONNECTION_THICKNESS,\n })\nend\n\n-- Draws a one-way location connection between the two cards, adding the lines to do so to the\n-- given lines list. Arrows will point towards the target card.\n---@param origin tts__Object Origin card in the connection\n---@param target tts__Object Target card object to connect\n---@param vectorOwner tts__Object The object which these lines will be set to. Used for relative\n--- positioning and scaling, as well as highlighting connections during a drag operation\n---@param lines table List of vector line elements. Mutable, will be updated to add this connector\nfunction addOneWayVector(origin, target, vectorOwner, lines)\n -- Start with the BiDi then add the arrow lines to it\n addBidirectionalVector(origin, target, vectorOwner, lines)\n local originPos = origin.getPosition()\n local targetPos = target.getPosition()\n originPos.y = CONNECTION_LINE_Y\n targetPos.y = CONNECTION_LINE_Y\n\n -- Calculate card distance to be closer for horizontal positions than vertical, since cards are\n -- taller than they are wide\n local heading = Vector(originPos):sub(targetPos):heading(\"y\")\n local distanceFromCard = DIRECTIONAL_ARROW_DISTANCE * 0.7 + DIRECTIONAL_ARROW_DISTANCE * 0.3 * math.abs(math.sin(math.rad(heading)))\n\n -- Calculate the three possible arrow positions. These are offset by half the arrow length to\n -- make them visually balanced by keeping the arrows centered, not tracking the point\n local midpoint = Vector(originPos):add(targetPos):scale(0.5):moveTowards(targetPos, ARROW_ARM_LENGTH / 2)\n local closeToOrigin = Vector(originPos):moveTowards(targetPos, distanceFromCard + ARROW_ARM_LENGTH / 2)\n local closeToTarget = Vector(targetPos):moveTowards(originPos, distanceFromCard - ARROW_ARM_LENGTH / 2)\n\n if (originPos:distance(closeToOrigin) \u003e originPos:distance(closeToTarget)) then\n addArrowLines(midpoint, originPos, vectorOwner, lines)\n else\n addArrowLines(closeToOrigin, originPos, vectorOwner, lines)\n addArrowLines(closeToTarget, originPos, vectorOwner, lines)\n end\nend\n\n-- Draws an arrowhead at the given position.\n---@param arrowheadPos tts__Vector Centerpoint of the arrowhead to draw (NOT the tip of the arrow)\n---@param originPos tts__Vector Origin point of the connection, used to position the arrow arms\n---@param vectorOwner tts__Object The object which these lines will be set to. Used for relative\n--- positioning and scaling, as well as highlighting connections during a drag operation\n---@param lines table List of vector line elements. Mutable, will be updated to add this arrow\nfunction addArrowLines(arrowheadPos, originPos, vectorOwner, lines)\n local arrowArm1 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver(\"y\", -1 * ARROW_ANGLE):add(arrowheadPos)\n local arrowArm2 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver(\"y\", ARROW_ANGLE):add(arrowheadPos)\n\n local head = vectorOwner.positionToLocal(arrowheadPos)\n local arm1 = vectorOwner.positionToLocal(arrowArm1)\n local arm2 = vectorOwner.positionToLocal(arrowArm2)\n table.insert(lines, {\n points = { arm1, head, arm2 },\n color = vectorOwner == self and connectionColor or DRAGGING_CONNECTION_COLOR,\n thickness = vectorOwner == self and CONNECTION_THICKNESS or DRAGGING_CONNECTION_THICKNESS,\n })\nend\n\n-- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n-- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n---@param playerColor string Color of the player requesting the shift. Used solely to send an error\n--- message in the unlikely case that the scripting zone has been deleted\nfunction shiftContentsUp(playerColor)\n shiftContents(playerColor, \"up\")\nend\n\nfunction shiftContentsDown(playerColor)\n shiftContents(playerColor, \"down\")\nend\n\nfunction shiftContentsLeft(playerColor)\n shiftContents(playerColor, \"left\")\nend\n\nfunction shiftContentsRight(playerColor)\n shiftContents(playerColor, \"right\")\nend\n\nfunction shiftContents(playerColor, direction)\n local zone = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayAreaZone\")\n if not zone then\n broadcastToColor(\"Scripting zone couldn't be found.\", playerColor, \"Red\")\n return\n end\n\n for _, object in ipairs(zone.getObjects()) do\n if not (SHIFT_EXCLUSION[object.getGUID()] or object.hasTag(\"displacement_excluded\")) then\n object.translate(SHIFT_OFFSETS[direction])\n end\n end\n Wait.time(drawBaseConnections, 0.1)\nend\n\n-- Check to see if the given object is within the bounds of the play area, based solely on the X and\n-- Z coordinates, ignoring height\n---@param object tts__Object Object to check\n---@return boolean: True if the object is inside the play area\nfunction isInPlayArea(object)\n local bounds = self.getBounds()\n local position = object.getPosition()\n -- Corners are arbitrary since it's all global - c1 goes down both axes, c2 goes up\n local c1 = { x = bounds.center.x - bounds.size.x / 2, z = bounds.center.z - bounds.size.z / 2 }\n local c2 = { x = bounds.center.x + bounds.size.x / 2, z = bounds.center.z + bounds.size.z / 2 }\n\n return position.x \u003e c1.x and position.x \u003c c2.x and position.z \u003e c1.z and position.z \u003c c2.z\nend\n\nfunction onScenarioChanged(scenarioName)\n currentScenario = scenarioName\n if not showLocationLinks() then\n broadcastToAll(\"Automatic location connections not available for this scenario\")\n end\nend\n\nfunction showLocationLinks()\n return not LOC_LINK_EXCLUDE_SCENARIOS[currentScenario] and connectionsEnabled\nend\n\n-- Sets this playmat's snap points to limit snapping to locations or not.\n-- If matchTypes is false, snap points will be reset to snap all cards.\n---@param matchTypes boolean Whether snap points should only snap for the matching card types.\nfunction setLimitSnapsByType(matchTypes)\n local snaps = self.getSnapPoints()\n for i, snap in ipairs(snaps) do\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Location\" }\n else\n table.insert(snaps[i].tags, \"Location\")\n end\n else\n snaps[i].tags = nil\n end\n end\n self.setSnapPoints(snaps)\nend\n\n-- called by the option panel to enabled / disable location connections\nfunction setConnectionDrawState(state)\n connectionsEnabled = state\n rebuildConnectionList()\n drawBaseConnections()\nend\n\n-- called by the option panel to edit the location connection color\nfunction setConnectionColor(color)\n connectionColor = color\n rebuildConnectionList()\n drawBaseConnections()\nend\n\n-- count victory points on locations in play area\n---@param highlightOff boolean True if highlighting should be enabled\n---@return. Returns the total amount of VP found in the play area\nfunction countVP(highlightOff)\n local totalVP = 0\n\n for cardId, metadata in pairs(locations) do\n local card = getObjectFromGUID(cardId)\n if metadata ~= nil and card ~= nil then\n if highlightOff == true then\n card.highlightOff(\"Green\")\n end\n\n local cardVP = tonumber(metadata.victory) or 0\n if cardVP ~= 0 and not cardHasClues(card) then\n totalVP = totalVP + cardVP\n if highlightOff == false then\n card.highlightOn(\"Green\")\n end\n end\n end\n end\n\n return totalVP\nend\n\n-- checks if a card has clues on it, returns true if clues are on it\n---@param card tts__Object Card to check for clues\nfunction cardHasClues(card)\n local searchResult = searchLib.onObject(card, \"isClue\")\n return #searchResult \u003e 0\nend\n\n-- highlights all locations in the play area without metadata\n---@param state boolean True if highlighting should be enabled\nfunction highlightMissingData(state)\n for i, obj in pairs(missingData) do\n if obj ~= nil then\n if state then\n obj.highlightOff(\"Red\")\n else\n obj.highlightOn(\"Red\")\n end\n else\n missingData[i] = nil\n end\n end\nend\n\n-- rebuilds local snap points (could be useful in the future again)\nfunction buildSnaps()\n local upperleft = { x = 1.53, z = -1.09 }\n local lowerright = { x = -1.53, z = 1.55 }\n local snaps = {}\n\n -- creates 81 snap points, for uneven rows + columns it makes a rotation snap point\n for i = 1, 9 do\n for j = 1, 9 do\n local snap = {}\n snap.position = {}\n snap.position.x = round(upperleft.x - (upperleft.x - lowerright.x) * (i - 1) / 8, 3)\n snap.position.y = 0.1\n snap.position.z = round(upperleft.z - (upperleft.z - lowerright.z) * (j - 1) / 8, 3)\n\n -- enable rotation snaps for uneven rows / columns\n if (i % 2 ~= 0) and (j % 2 ~= 0) then\n snap.rotation = { 0, 0, 0 }\n snap.rotation_snap = true\n end\n\n table.insert(snaps, snap)\n end\n end\n self.setSnapPoints(snaps)\nend\n\n-- utility function\nfunction round(num, numDecimalPlaces)\n local mult = 10 ^ (numDecimalPlaces or 0)\n return math.floor(num * mult + 0.5) / mult\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror\n -- tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned) spawned.setState(tokenValue) end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/PlayArea\")\nend)\n__bundle_register(\"core/PlayArea\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenManager = require(\"core/token/TokenManager\")\n\n-- Location connection directional options\nlocal BIDIRECTIONAL = 0\nlocal ONE_WAY = 1\nlocal INCOMING_ONE_WAY = 2\n\n-- Connector draw parameters\nlocal CONNECTION_THICKNESS = 0.015\nlocal DRAGGING_CONNECTION_THICKNESS = 0.15\nlocal DRAGGING_CONNECTION_COLOR = { 0.8, 0.8, 0.8, 1 }\nlocal DIRECTIONAL_ARROW_DISTANCE = 3.5\nlocal ARROW_ARM_LENGTH = 0.9\nlocal ARROW_ANGLE = 25\n\n-- Height to draw the connector lines, places them just above the table and always below cards\nlocal CONNECTION_LINE_Y = 1.529\n\n-- used for recreating the link to a custom data helper after image change\ncustomDataHelper = nil\n\nlocal DEFAULT_URL = \"http://cloud-3.steamusercontent.com/ugc/998015670465071049/FFAE162920D67CF38045EFBD3B85AD0F916147B2/\"\n\nlocal SHIFT_OFFSETS = {\n left = { x = 0.00, y = 0, z = 7.67 },\n right = { x = 0.00, y = 0, z = -7.67 },\n up = { x = 6.54, y = 0, z = 0.00 },\n down = { x = -6.54, y = 0, z = 0.00 }\n}\nlocal SHIFT_EXCLUSION = {\n [\"b7b45b\"] = true,\n [\"f182ee\"] = true,\n [\"721ba2\"] = true\n}\nlocal LOC_LINK_EXCLUDE_SCENARIOS = {\n [\"The Witching Hour\"] = true,\n [\"The Heart of Madness\"] = true\n}\n\nlocal locations = {}\nlocal locationConnections = {}\nlocal draggingGuids = {}\nlocal missingData = {}\nlocal collisionEnabled = false\nlocal currentScenario, connectionsEnabled\n\n---------------------------------------------------------\n-- general code\n---------------------------------------------------------\n\nfunction onSave()\n return JSON.encode({\n trackedLocations = locations,\n currentScenario = currentScenario,\n connectionColor = connectionColor,\n connectionsEnabled = connectionsEnabled\n })\nend\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData) or {}\n locations = loadedData.trackedLocations or {}\n currentScenario = loadedData.currentScenario\n connectionColor = loadedData.connectionColor or { 0.4, 0.4, 0.4, 1 }\n connectionsEnabled = loadedData.connectionsEnabled or true\n end\n\n -- this needs to be here since the playarea will be reloaded when the image changes\n self.interactable = false\n\n Wait.time(function() collisionEnabled = true end, 0.1)\nend\n\n-- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n-- data to the local token manager instance.\n---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\nfunction updateLocations(args)\n customDataHelper = getObjectFromGUID(args[1])\n if customDataHelper ~= nil then\n tokenManager.addLocationData(customDataHelper.getTable(\"LOCATIONS_DATA\"))\n end\nend\n\n---------------------------------------------------------\n-- TTS event handling\n---------------------------------------------------------\n\nfunction onCollisionEnter(collisionInfo)\n if not collisionEnabled then return end\n\n local object = collisionInfo.collision_object\n\n if object.type == \"Deck\" then\n table.insert(missingData, object)\n end\n\n -- only continue for cards\n if object.type ~= \"Card\" then return end\n\n -- check if we should spawn clues here and do so according to playercount\n if shouldSpawnTokens(object) then\n tokenManager.spawnForCard(object)\n end\n\n -- If this card was being dragged, clear the dragging connections. A multi-drag/drop may send\n -- the dropped card immediately into a deck, so this has to be done here\n if draggingGuids[object.getGUID()] ~= nil then\n object.setVectorLines({})\n draggingGuids[object.getGUID()] = nil\n end\n\n maybeTrackLocation(object)\nend\n\nfunction onCollisionExit(collisionInfo)\n maybeUntrackLocation(collisionInfo.collision_object)\nend\n\n-- Destroyed objects don't trigger onCollisionExit(), so check on destruction to untrack as well\nfunction onObjectDestroy(object)\n maybeUntrackLocation(object)\nend\n\nfunction onObjectPickUp(_, object)\n if object.type ~= \"Card\" then return end\n\n -- onCollisionExit USUALLY fires first, so we have to check the card to see if it's a location we should be tracking\n if showLocationLinks() and isInPlayArea(object) and object.getGMNotes() ~= nil and object.getGMNotes() ~= \"\" then\n local pickedUpGuid = object.getGUID()\n local metadata = JSON.decode(object.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n -- onCollisionExit sometimes comes 1 frame after onObjectPickUp (rather than before it or in\n -- the same frame). This causes a mismatch in the data between dragging the on-table, and\n -- that one frame draws connectors on the card which then show up as shadows for snap points.\n -- Waiting ensures we always do thing in the expected Exit-\u003ePickUp order\n Wait.frames(function()\n if object.is_face_down then\n draggingGuids[pickedUpGuid] = metadata.locationBack\n else\n draggingGuids[pickedUpGuid] = metadata.locationFront\n end\n rebuildConnectionList()\n end, 2)\n end\n end\nend\n\n-- Due to the frequence of onUpdate calls, ensure that we only process any changes once\nfunction onUpdate()\n local needsConnectionRebuild = false\n local needsConnectionDraw = false\n for guid, _ in pairs(draggingGuids) do\n local obj = getObjectFromGUID(guid)\n if obj == nil or not isInPlayArea(obj) then\n draggingGuids[guid] = nil\n needsConnectionRebuild = true\n -- If object still exists then it's outside the area and needs to lose the lines attached to it\n if obj ~= nil then\n obj.setVectorLines({})\n end\n end\n -- Even if the last location left the play area, need one last draw to clear the lines\n needsConnectionDraw = true\n end\n if needsConnectionRebuild then\n rebuildConnectionList()\n end\n if needsConnectionDraw then\n drawDraggingConnections()\n end\nend\n\n-- Global event handler, delegated from Global. Clears any connection lines from dragged cards\n-- before they are destroyed by entering a deck. Removal of the card from the dragging list will\n-- be handled during the next onUpdate() call.\nfunction tryObjectEnterContainer()\n for draggedGuid, _ in pairs(draggingGuids) do\n local draggedObj = getObjectFromGUID(draggedGuid)\n if draggedObj ~= nil then\n draggedObj.setVectorLines({})\n end\n end\nend\n\n---------------------------------------------------------\n-- main functionality\n---------------------------------------------------------\n\nfunction shouldSpawnTokens(card)\n local metadata = JSON.decode(card.getGMNotes())\n if metadata == nil then\n return tokenManager.hasLocationData(card)\n end\n return metadata.type == \"Location\"\n or metadata.type == \"Enemy\"\n or metadata.type == \"Treachery\"\n or metadata.weakness\n -- hardcoded IDs for \"Makeshift Trap\" and \"Shrine of the Moirai\"\n -- these cards are events with uses, that attach to encounter cards and thus will enter play in the playarea\n -- TODO: probably turn this into a metadata field if we get more cards like that\n or metadata.id == \"07310\"\n or metadata.id == \"09100\"\nend\n\n-- Checks the given card and adds it to the list of locations tracked for connection purposes.\n-- A card will be added to the tracking if it is a location in the play area (based on centerpoint).\n---@param card tts__Object A card object, possibly a location.\nfunction maybeTrackLocation(card)\n -- Collision checks for any part of the card overlap, but our other tracking is centerpoint\n -- Ignore any collision where the centerpoint isn't in the area\n if isInPlayArea(card) then\n local metadata = JSON.decode(card.getGMNotes())\n if metadata == nil then\n table.insert(missingData, card)\n else\n if metadata.type == \"Location\" then\n if card.is_face_down then\n locations[card.getGUID()] = metadata.locationBack\n else\n locations[card.getGUID()] = metadata.locationFront\n end\n\n -- only draw connection lines for not-excluded scenarios\n if showLocationLinks() then\n rebuildConnectionList()\n drawBaseConnections()\n end\n end\n end\n end\nend\n\n-- Stop tracking a location for connection drawing. This should be called for both collision exit\n-- and destruction, as a destroyed object does not trigger collision exit. An object can also be\n-- deleted mid-drag, but the ordering for drag events means we can't clear those here and those will\n-- be cleared in the next onUpdate() cycle.\n---@param card tts__Object Card to (maybe) stop tracking\nfunction maybeUntrackLocation(card)\n -- Locked objects no longer collide (hence triggering an exit event) but are still in the play\n -- area. If the object is now locked, don't remove it.\n if locations[card.getGUID()] ~= nil and not card.locked then\n locations[card.getGUID()] = nil\n rebuildConnectionList()\n drawBaseConnections()\n end\nend\n\n-- Builds a list of GUID to GUID connection information based on the currently tracked locations.\n-- This will update the connection information and store it in the locationConnections data member,\n-- but does not draw those connections. This should often be followed by a call to drawBaseConnections()\nfunction rebuildConnectionList()\n if not showLocationLinks() then\n locationConnections = {}\n return\n end\n\n local iconCardList = {}\n\n -- Build a list of cards with each icon as their location ID\n for cardId, metadata in pairs(draggingGuids) do\n buildLocListByIcon(cardId, iconCardList, metadata)\n end\n for cardId, metadata in pairs(locations) do\n buildLocListByIcon(cardId, iconCardList, metadata)\n end\n\n -- Pair up all the icons\n locationConnections = {}\n for cardId, metadata in pairs(draggingGuids) do\n buildConnection(cardId, iconCardList, metadata)\n end\n for cardId, metadata in pairs(locations) do\n if draggingGuids[cardId] == nil then\n buildConnection(cardId, iconCardList, metadata)\n end\n end\nend\n\n-- Extracts the card's icon string into a list of individual location icons\n---@param cardId string GUID of the card to pull the icon data from\n---@param iconCardList table A table of icon-\u003eGUID list. Mutable, will be updated by this method\n---@param locData table A table containing the metadata for the card (for the correct side)\nfunction buildLocListByIcon(cardId, iconCardList, locData)\n if locData ~= nil and locData.icons ~= nil then\n for icon in string.gmatch(locData.icons, \"%a+\") do\n if iconCardList[icon] == nil then\n iconCardList[icon] = {}\n end\n table.insert(iconCardList[icon], cardId)\n end\n end\nend\n\n-- Builds the connections for the given cardID by finding matching icons and adding them to the\n-- Playarea's locationConnections table.\n---@param cardId string GUID of the card to build the connections for\n---@param iconCardList table A table of icon-\u003eGUID List. Used to find matching icons for connections.\n---@param locData table A table containing the metadata for the card (for the correct side)\nfunction buildConnection(cardId, iconCardList, locData)\n if locData ~= nil and locData.connections ~= nil then\n locationConnections[cardId] = {}\n for icon in string.gmatch(locData.connections, \"%a+\") do\n if iconCardList[icon] ~= nil then\n for _, connectedGuid in ipairs(iconCardList[icon]) do\n -- If the reciprocal exists, convert it to BiDi, otherwise add as a one-way\n if locationConnections[connectedGuid] ~= nil\n and (locationConnections[connectedGuid][cardId] == ONE_WAY\n or locationConnections[connectedGuid][cardId] == BIDIRECTIONAL) then\n locationConnections[connectedGuid][cardId] = BIDIRECTIONAL\n locationConnections[cardId][connectedGuid] = nil\n else\n if locationConnections[connectedGuid] == nil then\n locationConnections[connectedGuid] = {}\n end\n locationConnections[cardId][connectedGuid] = ONE_WAY\n locationConnections[connectedGuid][cardId] = INCOMING_ONE_WAY\n end\n end\n end\n end\n end\nend\n\n-- Draws the lines for connections currently in locationConnections but not in draggingGuids.\nfunction drawBaseConnections()\n if not showLocationLinks() then\n locationConnections = {}\n self.setVectorLines({})\n return\n end\n local cardConnectionLines = {}\n\n for originGuid, targetGuids in pairs(locationConnections) do\n -- Objects should reliably exist at this point, but since this can be called during onUpdate the\n -- object checks are conservative just to make sure.\n local origin = getObjectFromGUID(originGuid)\n if draggingGuids[originGuid] == nil and origin ~= nil then\n for targetGuid, direction in pairs(targetGuids) do\n local target = getObjectFromGUID(targetGuid)\n if draggingGuids[targetGuid] == nil and target ~= nil then\n -- Since we process the full list, we're guaranteed to hit any ONE_WAY connections later\n -- so we can ignore INCOMING_ONE_WAY\n if direction == BIDIRECTIONAL then\n addBidirectionalVector(origin, target, self, cardConnectionLines)\n elseif direction == ONE_WAY then\n addOneWayVector(origin, target, self, cardConnectionLines)\n end\n end\n end\n end\n end\n self.setVectorLines(cardConnectionLines)\nend\n\n-- Draws the lines for cards which are currently being dragged.\nfunction drawDraggingConnections()\n if not showLocationLinks() then return end\n local ownedVectors = {}\n\n for originGuid, _ in pairs(draggingGuids) do\n targetGuids = locationConnections[originGuid]\n -- Objects should reliably exist at this point, but since this can be called during onUpdate the\n -- object checks are conservative just to make sure.\n local origin = getObjectFromGUID(originGuid)\n if draggingGuids[originGuid] and origin ~= nil and targetGuids ~= nil then\n ownedVectors[originGuid] = {}\n for targetGuid, direction in pairs(targetGuids) do\n local target = getObjectFromGUID(targetGuid)\n if target ~= nil then\n if direction == BIDIRECTIONAL then\n addBidirectionalVector(origin, target, origin, ownedVectors[originGuid])\n elseif direction == ONE_WAY then\n addOneWayVector(origin, target, origin, ownedVectors[originGuid])\n elseif direction == INCOMING_ONE_WAY and not draggingGuids[targetGuid] then\n addOneWayVector(target, origin, origin, ownedVectors[originGuid])\n end\n end\n end\n end\n end\n for ownerGuid, vectors in pairs(ownedVectors) do\n local card = getObjectFromGUID(ownerGuid)\n card.setVectorLines(vectors)\n end\nend\n\n-- Draws a bidirectional location connection between the two cards, adding the necessary lines to the list\n---@param card1 tts__Object One of the card objects to connect\n---@param card2 tts__Object The other card object to connect\n---@param vectorOwner tts__Object The object which these lines will be set to. Used for relative\n--- positioning and scaling, as well as highlighting connections during a drag operation\n---@param lines table List of vector line elements. Mutable, will be updated to add this connector\nfunction addBidirectionalVector(card1, card2, vectorOwner, lines)\n local cardPos1 = card1.getPosition()\n local cardPos2 = card2.getPosition()\n cardPos1.y = CONNECTION_LINE_Y\n cardPos2.y = CONNECTION_LINE_Y\n\n local pos1 = vectorOwner.positionToLocal(cardPos1)\n local pos2 = vectorOwner.positionToLocal(cardPos2)\n\n table.insert(lines, {\n points = { pos1, pos2 },\n color = vectorOwner == self and connectionColor or DRAGGING_CONNECTION_COLOR,\n thickness = vectorOwner == self and CONNECTION_THICKNESS or DRAGGING_CONNECTION_THICKNESS,\n })\nend\n\n-- Draws a one-way location connection between the two cards, adding the lines to do so to the\n-- given lines list. Arrows will point towards the target card.\n---@param origin tts__Object Origin card in the connection\n---@param target tts__Object Target card object to connect\n---@param vectorOwner tts__Object The object which these lines will be set to. Used for relative\n--- positioning and scaling, as well as highlighting connections during a drag operation\n---@param lines table List of vector line elements. Mutable, will be updated to add this connector\nfunction addOneWayVector(origin, target, vectorOwner, lines)\n -- Start with the BiDi then add the arrow lines to it\n addBidirectionalVector(origin, target, vectorOwner, lines)\n local originPos = origin.getPosition()\n local targetPos = target.getPosition()\n originPos.y = CONNECTION_LINE_Y\n targetPos.y = CONNECTION_LINE_Y\n\n -- Calculate distance to be closer for horizontal positions than vertical, since cards are taller than wide\n local heading = Vector(originPos):sub(targetPos):heading(\"y\")\n local distanceFromCard = DIRECTIONAL_ARROW_DISTANCE * 0.7 + DIRECTIONAL_ARROW_DISTANCE * 0.3 * math.abs(math.sin(math.rad(heading)))\n\n -- Calculate the three possible arrow positions. These are offset by half the arrow length to\n -- make them visually balanced by keeping the arrows centered, not tracking the point\n local midpoint = Vector(originPos):add(targetPos):scale(0.5):moveTowards(targetPos, ARROW_ARM_LENGTH / 2)\n local closeToOrigin = Vector(originPos):moveTowards(targetPos, distanceFromCard + ARROW_ARM_LENGTH / 2)\n local closeToTarget = Vector(targetPos):moveTowards(originPos, distanceFromCard - ARROW_ARM_LENGTH / 2)\n\n if (originPos:distance(closeToOrigin) \u003e originPos:distance(closeToTarget)) then\n addArrowLines(midpoint, originPos, vectorOwner, lines)\n else\n addArrowLines(closeToOrigin, originPos, vectorOwner, lines)\n addArrowLines(closeToTarget, originPos, vectorOwner, lines)\n end\nend\n\n-- Draws an arrowhead at the given position.\n---@param arrowheadPos tts__Vector Centerpoint of the arrowhead to draw (NOT the tip of the arrow)\n---@param originPos tts__Vector Origin point of the connection, used to position the arrow arms\n---@param vectorOwner tts__Object The object which these lines will be set to. Used for relative\n--- positioning and scaling, as well as highlighting connections during a drag operation\n---@param lines table List of vector line elements. Mutable, will be updated to add this arrow\nfunction addArrowLines(arrowheadPos, originPos, vectorOwner, lines)\n local arrowArm1 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver(\"y\", -1 * ARROW_ANGLE):add(arrowheadPos)\n local arrowArm2 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver(\"y\", ARROW_ANGLE):add(arrowheadPos)\n\n local head = vectorOwner.positionToLocal(arrowheadPos)\n local arm1 = vectorOwner.positionToLocal(arrowArm1)\n local arm2 = vectorOwner.positionToLocal(arrowArm2)\n table.insert(lines, {\n points = { arm1, head, arm2 },\n color = vectorOwner == self and connectionColor or DRAGGING_CONNECTION_COLOR,\n thickness = vectorOwner == self and CONNECTION_THICKNESS or DRAGGING_CONNECTION_THICKNESS,\n })\nend\n\n-- count victory points on locations in play area\n---@param highlightOff boolean True if highlighting should be enabled\n---@return. Returns the total amount of VP found in the play area\nfunction countVP(highlightOff)\n local totalVP = 0\n\n for cardId, metadata in pairs(locations) do\n local card = getObjectFromGUID(cardId)\n if metadata ~= nil and card ~= nil then\n if highlightOff == true then\n card.highlightOff(\"Green\")\n end\n\n local cardVP = tonumber(metadata.victory) or 0\n if cardVP ~= 0 and not cardHasClues(card) then\n totalVP = totalVP + cardVP\n if highlightOff == false then\n card.highlightOn(\"Green\")\n end\n end\n end\n end\n\n return totalVP\nend\n\n-- checks if a card has clues on it, returns true if clues are on it\n---@param card tts__Object Card to check for clues\nfunction cardHasClues(card)\n local searchResult = searchLib.onObject(card, \"isClue\")\n return #searchResult \u003e 0\nend\n\n-- highlights all locations in the play area without metadata\n---@param state boolean True if highlighting should be enabled\nfunction highlightMissingData(state)\n for i, obj in pairs(missingData) do\n if obj ~= nil then\n if state then\n obj.highlightOff(\"Red\")\n else\n obj.highlightOn(\"Red\")\n end\n else\n missingData[i] = nil\n end\n end\nend\n\n---------------------------------------------------------\n-- functions for outside calls\n---------------------------------------------------------\n\n-- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n-- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n---@param playerColor string Color of the player requesting the shift (used for error messages)\nfunction shiftContentsUp(playerColor)\n shiftContents(playerColor, \"up\")\nend\n\nfunction shiftContentsDown(playerColor)\n shiftContents(playerColor, \"down\")\nend\n\nfunction shiftContentsLeft(playerColor)\n shiftContents(playerColor, \"left\")\nend\n\nfunction shiftContentsRight(playerColor)\n shiftContents(playerColor, \"right\")\nend\n\nfunction shiftContents(playerColor, direction)\n local zone = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayAreaZone\")\n if not zone then\n broadcastToColor(\"Scripting zone couldn't be found.\", playerColor, \"Red\")\n return\n end\n\n for _, object in ipairs(zone.getObjects()) do\n if not (SHIFT_EXCLUSION[object.getGUID()] or object.hasTag(\"displacement_excluded\")) then\n object.translate(SHIFT_OFFSETS[direction])\n end\n end\n Wait.time(drawBaseConnections, 0.1)\nend\n\n-- sets the image of the playarea\n---@param newURL string URL for the new surface image\nfunction updateSurface(newURL)\n local customInfo = self.getCustomObject()\n\n if newURL ~= \"\" and newURL ~= nil and newURL ~= DEFAULT_URL then\n customInfo.image = newURL\n broadcastToAll(\"New Playarea Image Applied\", \"Green\")\n else\n customInfo.image = DEFAULT_URL\n broadcastToAll(\"Default Playarea Image Applied\", \"Green\")\n end\n\n self.setCustomObject(customInfo)\n\n local guid = nil\n if customDataHelper then\n guid = customDataHelper.getGUID()\n end\n\n self.reload()\n\n if guid ~= nil then\n Wait.time(function() updateLocations({ guid }) end, 1)\n end\nend\n\n-- Toggles the tags for the playarea's snap points to limit snapping to locations or not\n-- If matchTypes is false, snap points will be reset to snap all cards\n---@param matchTypes boolean Whether snap points should only snap for the matching card types\nfunction setLimitSnapsByType(matchTypes)\n local snaps = self.getSnapPoints()\n for _, snap in ipairs(snaps) do\n if matchTypes then\n if snap.tags == nil then\n snap.tags = { \"Location\" }\n else\n table.insert(snap.tags, \"Location\")\n end\n else\n snap.tags = nil\n end\n end\n self.setSnapPoints(snaps)\nend\n\n-- called by the option panel to enabled / disable location connections\nfunction setConnectionDrawState(state)\n connectionsEnabled = state\n rebuildConnectionList()\n drawBaseConnections()\nend\n\n-- called by the option panel to edit the location connection color\nfunction setConnectionColor(color)\n connectionColor = color\n rebuildConnectionList()\n drawBaseConnections()\nend\n\nfunction onScenarioChanged(scenarioName)\n currentScenario = scenarioName\n if not showLocationLinks() then\n broadcastToAll(\"Automatic location connections not available for this scenario\")\n end\nend\n\nfunction getTrackedLocations()\n return locations\nend\n\n---------------------------------------------------------\n-- utility functions\n---------------------------------------------------------\n\n-- Check to see if the given object is within the bounds of the play area (using X and Z coordinates)\n---@param object tts__Object Object to check\n---@return boolean: True if the object is inside the play area\nfunction isInPlayArea(object)\n local bounds = self.getBounds()\n local position = object.getPosition()\n -- Corners are arbitrary since it's all global - c1 goes down both axes, c2 goes up\n local c1 = { x = bounds.center.x - bounds.size.x / 2, z = bounds.center.z - bounds.size.z / 2 }\n local c2 = { x = bounds.center.x + bounds.size.x / 2, z = bounds.center.z + bounds.size.z / 2 }\n\n return position.x \u003e c1.x and position.x \u003c c2.x and position.z \u003e c1.z and position.z \u003c c2.z\nend\n\nfunction showLocationLinks()\n return not LOC_LINK_EXCLUDE_SCENARIOS[currentScenario] and connectionsEnabled\nend\n\nfunction round(num, numDecimalPlaces)\n local mult = 10 ^ (numDecimalPlaces or 0)\n return math.floor(num * mult + 0.5) / mult\nend\n\n-- rebuilds local snap points (could be useful in the future again)\nfunction buildSnaps()\n local upperleft = { x = 1.53, z = -1.09 }\n local lowerright = { x = -1.53, z = 1.55 }\n local snaps = {}\n\n -- creates 81 snap points, for uneven rows + columns it makes a rotation snap point\n for i = 1, 9 do\n for j = 1, 9 do\n local snap = {}\n snap.position = {}\n snap.position.x = round(upperleft.x - (upperleft.x - lowerright.x) * (i - 1) / 8, 3)\n snap.position.y = 0.1\n snap.position.z = round(upperleft.z - (upperleft.z - lowerright.z) * (j - 1) / 8, 3)\n\n -- enable rotation snaps for uneven rows / columns\n if (i % 2 ~= 0) and (j % 2 ~= 0) then\n snap.rotation = { 0, 0, 0 }\n snap.rotation_snap = true\n end\n\n table.insert(snaps, snap)\n end\n end\n self.setSnapPoints(snaps)\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned)\n -- token starts in state 1, so don't attempt to change it to avoid error\n if tokenValue ~= 1 then\n spawned.setState(tokenValue)\n end\n end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "{\"connectionColor\":{\"a\":1,\"b\":0.4,\"g\":0.4,\"r\":0.4},\"connectionsEnabled\":true,\"trackedLocations\":[]}", "MeasureMovement": false, "Name": "Custom_Token", @@ -20432,7 +20442,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"arkhamdb/HotfixBag\")\nend)\n__bundle_register(\"arkhamdb/HotfixBag\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- A Hotfix bag contains replacement cards for the All Cards Bag, and should\n-- have the 'AllCardsHotfix' tag on the object. Code for the All Cards Bag will\n-- find these bags during indexing, and use them to replace cards from the\n-- actual bag.\n\n-- Tells the All Cards Bag to recreate its indexes. The All Cards Bag may\n-- ignore this request; see the rebuildIndexForHotfix() method in the All Cards\n-- Bag for details.\n\nlocal allCardsBagApi = require(\"playercards/AllCardsBagApi\")\n\nfunction onLoad()\n allCardsBagApi.rebuildIndexForHotfix()\n self.addContextMenuItem(\"Update card index\", function() allCardsBagApi.rebuildIndexForHotfix() end)\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/AllCardsBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local AllCardsBagApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getAllCardsBag()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"AllCardsBag\")\n end\n\n -- Returns a specific card from the bag, based on ArkhamDB ID\n ---@param id table String ID of the card to retrieve\n ---@return table table\n -- If the indexes are still being constructed, an empty table is\n -- returned. Otherwise, a single table with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardById = function(id)\n return getAllCardsBag().call(\"getCardById\", {id = id})\n end\n\n -- Gets a random basic weakness from the bag. Once a given ID has been returned\n -- it will be removed from the list and cannot be selected again until a reload\n -- occurs or the indexes are rebuilt, which will refresh the list to include all\n -- weaknesses.\n ---@return string: ID of the selected weakness.\n AllCardsBagApi.getRandomWeaknessId = function()\n return getAllCardsBag().call(\"getRandomWeaknessId\")\n end\n\n AllCardsBagApi.isIndexReady = function()\n return getAllCardsBag().call(\"isIndexReady\")\n end\n\n -- Called by Hotfix bags when they load. If we are still loading indexes, then\n -- the all cards and hotfix bags are being loaded together, and we can ignore\n -- this call as the hotfix will be included in the initial indexing. If it is\n -- called once indexing is complete it means the hotfix bag has been added\n -- later, and we should rebuild the index to integrate the hotfix bag.\n AllCardsBagApi.rebuildIndexForHotfix = function()\n return getAllCardsBag().call(\"rebuildIndexForHotfix\")\n end\n\n -- Searches the bag for cards which match the given name and returns a list. Note that this is\n -- an O(n) search without index support. It may be slow.\n ---@param name string or string fragment to search for names\n ---@param exact boolean Whether the name match should be exact\n AllCardsBagApi.getCardsByName = function(name, exact)\n return getAllCardsBag().call(\"getCardsByName\", {name = name, exact = exact})\n end\n\n AllCardsBagApi.isBagPresent = function()\n return getAllCardsBag() and true\n end\n\n -- Returns a list of cards from the bag matching a class and level (0 or upgraded)\n ---@param class string class to retrieve (\"Guardian\", \"Seeker\", etc)\n ---@param upgraded boolean true for upgraded cards (Level 1-5), false for Level 0\n ---@return table: If the indexes are still being constructed, returns an empty table.\n -- Otherwise, a list of tables, each with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded)\n return getAllCardsBag().call(\"getCardsByClassAndLevel\", {class = class, upgraded = upgraded})\n end\n\n AllCardsBagApi.getCardsByCycle = function(cycle)\n return getAllCardsBag().call(\"getCardsByCycle\", cycle)\n end\n\n AllCardsBagApi.getUniqueWeaknesses = function()\n return getAllCardsBag().call(\"getUniqueWeaknesses\")\n end\n\n return AllCardsBagApi\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"arkhamdb/HotfixBag\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- A Hotfix bag contains replacement cards for the All Cards Bag, and should\n-- have the 'AllCardsHotfix' tag on the object. Code for the All Cards Bag will\n-- find these bags during indexing, and use them to replace cards from the\n-- actual bag.\n\n-- Tells the All Cards Bag to recreate its indexes. The All Cards Bag may\n-- ignore this request; see the rebuildIndexForHotfix() method in the All Cards\n-- Bag for details.\n\nlocal allCardsBagApi = require(\"playercards/AllCardsBagApi\")\n\nfunction onLoad()\n allCardsBagApi.rebuildIndexForHotfix()\n self.addContextMenuItem(\"Update card index\", function() allCardsBagApi.rebuildIndexForHotfix() end)\nend\nend)\n__bundle_register(\"playercards/AllCardsBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local AllCardsBagApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getAllCardsBag()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"AllCardsBag\")\n end\n\n -- Returns a specific card from the bag, based on ArkhamDB ID\n ---@param id table String ID of the card to retrieve\n ---@return table table\n -- If the indexes are still being constructed, an empty table is\n -- returned. Otherwise, a single table with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardById = function(id)\n return getAllCardsBag().call(\"getCardById\", {id = id})\n end\n\n -- Gets a random basic weakness from the bag. Once a given ID has been returned\n -- it will be removed from the list and cannot be selected again until a reload\n -- occurs or the indexes are rebuilt, which will refresh the list to include all\n -- weaknesses.\n ---@return string: ID of the selected weakness.\n AllCardsBagApi.getRandomWeaknessId = function()\n return getAllCardsBag().call(\"getRandomWeaknessId\")\n end\n\n AllCardsBagApi.isIndexReady = function()\n return getAllCardsBag().call(\"isIndexReady\")\n end\n\n -- Called by Hotfix bags when they load. If we are still loading indexes, then\n -- the all cards and hotfix bags are being loaded together, and we can ignore\n -- this call as the hotfix will be included in the initial indexing. If it is\n -- called once indexing is complete it means the hotfix bag has been added\n -- later, and we should rebuild the index to integrate the hotfix bag.\n AllCardsBagApi.rebuildIndexForHotfix = function()\n return getAllCardsBag().call(\"rebuildIndexForHotfix\")\n end\n\n -- Searches the bag for cards which match the given name and returns a list. Note that this is\n -- an O(n) search without index support. It may be slow.\n ---@param name string or string fragment to search for names\n ---@param exact boolean Whether the name match should be exact\n AllCardsBagApi.getCardsByName = function(name, exact)\n return getAllCardsBag().call(\"getCardsByName\", {name = name, exact = exact})\n end\n\n AllCardsBagApi.isBagPresent = function()\n return getAllCardsBag() and true\n end\n\n -- Returns a list of cards from the bag matching a class and level (0 or upgraded)\n ---@param class string class to retrieve (\"Guardian\", \"Seeker\", etc)\n ---@param upgraded boolean true for upgraded cards (Level 1-5), false for Level 0\n ---@return table: If the indexes are still being constructed, returns an empty table.\n -- Otherwise, a list of tables, each with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded)\n return getAllCardsBag().call(\"getCardsByClassAndLevel\", {class = class, upgraded = upgraded})\n end\n\n AllCardsBagApi.getCardsByCycle = function(cycle)\n return getAllCardsBag().call(\"getCardsByCycle\", cycle)\n end\n\n AllCardsBagApi.getUniqueWeaknesses = function()\n return getAllCardsBag().call(\"getUniqueWeaknesses\")\n end\n\n return AllCardsBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"arkhamdb/HotfixBag\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, @@ -20540,7 +20550,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -20640,7 +20650,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"chaosbag/ChaosBagStatTracker\")\nend)\n__bundle_register(\"chaosbag/ChaosBagStatTracker\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- button calls respective function in \"Global\"\nfunction onLoad()\n self.createButton({\n click_function = \"handleStatTrackerClick\",\n tooltip = \"Left-Click: Print stats\\nRight-Click: Reset stats\",\n height = 1250,\n width = 1250,\n color = { 0, 0, 0, 0 }\n })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"chaosbag/ChaosBagStatTracker\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- button calls respective function in \"Global\"\nfunction onLoad()\n self.createButton({\n click_function = \"handleStatTrackerClick\",\n tooltip = \"Left-Click: Print stats\\nRight-Click: Reset stats\",\n height = 1250,\n width = 1250,\n color = { 0, 0, 0, 0 }\n })\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"chaosbag/ChaosBagStatTracker\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[true,0]", "MeasureMovement": false, "Name": "Custom_Token", @@ -20688,7 +20698,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"util/TokenSpawnTool\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror\n -- tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned) spawned.setState(tokenValue) end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"util/TokenSpawnTool\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenManager = require(\"core/token/TokenManager\")\nlocal TOKEN_INDEX = {}\nTOKEN_INDEX[3] = \"resourceCounter\"\nTOKEN_INDEX[4] = \"damage\"\nTOKEN_INDEX[5] = \"path\"\nTOKEN_INDEX[6] = \"horror\"\nTOKEN_INDEX[7] = \"doom\"\nTOKEN_INDEX[8] = \"clue\"\nTOKEN_INDEX[9] = \"resource\"\n\nlocal stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n}\n\n---@param index number Index of the pressed key\n---@param playerColor string Color of the triggering player\nfunction onScriptingButtonDown(index, playerColor)\n local tokenType = TOKEN_INDEX[index]\n if not tokenType then return end\n\n local rotation = { x = 0, y = Player[playerColor].getPointerRotation(), z = 0 }\n local position = Player[playerColor].getPointerPosition() + Vector(0, 0.2, 0)\n local subType = \"\"\n local callback = nil\n\n -- check for subtype of resource based on card below\n if tokenType == \"resource\" then\n for _, obj in ipairs(searchLib.belowPosition(position, \"isCard\")) do\n if not obj.is_face_down then\n local metadata = JSON.decode(obj.getGMNotes()) or {}\n local uses = metadata.uses or {}\n for _, useInfo in ipairs(uses) do\n if useInfo.token == \"resource\" then\n subType = useInfo.type\n break\n end\n end\n break\n end\n end\n \n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local stateID = stateTable[string.lower(subType)]\n if stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n -- check hovered object for \"resourceCounter\" tokens and increase them instead\n elseif tokenType == \"resourceCounter\" then\n local hoverObj = Player[playerColor].getHoverObject()\n if hoverObj then\n if tokenType == hoverObj.getMemo() then\n hoverObj.call(\"addOrSubtract\")\n return\n end\n end\n -- check hovered object for \"damage\" and \"horror\" tokens and increase them instead\n elseif tokenType == \"damage\" or tokenType == \"horror\" then\n local hoverObj = Player[playerColor].getHoverObject()\n if hoverObj then\n if tokenType == hoverObj.getMemo() then\n local stateInfo = hoverObj.getStates()\n local stateId = hoverObj.getStateId()\n if stateId \u003c= #stateInfo then\n hoverObj.setState(stateId + 1)\n return\n end\n end\n end\n end\n\n tokenManager.spawnToken(position, tokenType, rotation, callback)\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"util/TokenSpawnTool\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenManager = require(\"core/token/TokenManager\")\nlocal TOKEN_INDEX = {}\n\nTOKEN_INDEX[1] = \"actionToken\"\nTOKEN_INDEX[3] = \"resourceCounter\"\nTOKEN_INDEX[4] = \"damage\"\nTOKEN_INDEX[5] = \"path\"\nTOKEN_INDEX[6] = \"horror\"\nTOKEN_INDEX[7] = \"doom\"\nTOKEN_INDEX[8] = \"clue\"\nTOKEN_INDEX[9] = \"resource\"\n\nlocal stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n}\n\nlocal actionStateTable = {\n [\"Guardian\"] = 1,\n [\"Seeker\"] = 2,\n [\"Rogue\"] = 3,\n [\"Mystic\"] = 4,\n [\"Survivor\"] = 5,\n [\"Neutral\"] = 6\n}\n\n---@param index number Index of the pressed key\n---@param playerColor string Color of the triggering player\nfunction onScriptingButtonDown(index, playerColor)\n local tokenType = TOKEN_INDEX[index]\n if not tokenType then return end\n\n local rotation = { x = 0, y = Player[playerColor].getPointerRotation(), z = 0 }\n local position = Player[playerColor].getPointerPosition() + Vector(0, 0.2, 0)\n local subType = \"\"\n local callback = nil\n\n -- check for subtype of resource based on card below\n if tokenType == \"resource\" then\n for _, obj in ipairs(searchLib.belowPosition(position, \"isCard\")) do\n if not obj.is_face_down then\n local metadata = JSON.decode(obj.getGMNotes()) or {}\n local uses = metadata.uses or {}\n for _, useInfo in ipairs(uses) do\n if useInfo.token == \"resource\" then\n subType = useInfo.type\n break\n end\n end\n break\n end\n end\n \n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local stateID = stateTable[string.lower(subType)]\n if stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n -- check hovered object for \"resourceCounter\" tokens and increase them instead\n elseif tokenType == \"resourceCounter\" then\n local hoverObj = Player[playerColor].getHoverObject()\n if hoverObj then\n if tokenType == hoverObj.getMemo() then\n hoverObj.call(\"addOrSubtract\")\n return\n end\n end\n -- check hovered object for \"damage\" and \"horror\" tokens and increase them instead\n elseif tokenType == \"damage\" or tokenType == \"horror\" then\n local hoverObj = Player[playerColor].getHoverObject()\n if hoverObj then\n if tokenType == hoverObj.getMemo() then\n local stateInfo = hoverObj.getStates()\n local stateId = hoverObj.getStateId()\n if stateId \u003c= #stateInfo then\n hoverObj.setState(stateId + 1)\n return\n end\n end\n end\n -- check for nearest investigator card and change action token state to its class \n elseif tokenType == \"actionToken\" then\n local matColor = playmatApi.getMatColorByPosition(position)\n local result = playmatApi.searchAroundPlaymat(matColor, \"isCard\")\n local investigatorClass = \"Neutral\"\n for j, card in ipairs(result) do\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Investigator\" then\n investigatorClass = metadata.class\n end\n end\n\n local stateID = actionStateTable[investigatorClass]\n if stateID ~= nil and stateID ~= 6 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n end\n\n tokenManager.spawnToken(position, tokenType, rotation, callback)\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"util/TokenSpawnTool\")\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned)\n -- token starts in state 1, so don't attempt to change it to avoid error\n if tokenValue ~= 1 then\n spawned.setState(tokenValue)\n end\n end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Checker_white", @@ -20790,7 +20800,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -20876,7 +20886,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -20962,7 +20972,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -21048,7 +21058,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -21134,7 +21144,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -21220,7 +21230,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -21306,7 +21316,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -21392,7 +21402,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -21478,7 +21488,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -21564,7 +21574,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -21722,7 +21732,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -21808,7 +21818,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -21894,7 +21904,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -21980,7 +21990,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -22066,7 +22076,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -22152,7 +22162,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -22238,7 +22248,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -22364,7 +22374,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/Tarotcard\")\nend)\n__bundle_register(\"playercards/Tarotcard\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- context menu to manually fix rotation\nfunction onLoad()\n self.addContextMenuItem(\"Rotate Preview\", rotatePreview)\n self.addContextMenuItem(\"Rotate Card+Preview\", rotateSelfAndPreview)\nend\n\n-- rotates the alt_view_angle\nfunction rotatePreview()\n local angle = self.alt_view_angle\n if angle.y == 0 then\n angle.y = 180\n else\n angle.y = 0\n end\n self.alt_view_angle = angle\nend\n\n-- rotates this card and the preview\nfunction rotateSelfAndPreview()\n self.setRotationSmooth(self.getRotation() + Vector(0, 180, 0))\n rotatePreview()\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/Tarotcard\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- context menu to manually fix rotation\nfunction onLoad()\n self.addContextMenuItem(\"Rotate Preview\", rotatePreview)\n self.addContextMenuItem(\"Rotate Card+Preview\", rotateSelfAndPreview)\nend\n\n-- rotates the alt_view_angle\nfunction rotatePreview()\n local angle = self.alt_view_angle\n if angle.y == 0 then\n angle.y = 180\n else\n angle.y = 0\n end\n self.alt_view_angle = angle\nend\n\n-- rotates this card and the preview\nfunction rotateSelfAndPreview()\n self.setRotationSmooth(self.getRotation() + Vector(0, 180, 0))\n rotatePreview()\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/Tarotcard\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -22480,7 +22490,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/Tarotcard\")\nend)\n__bundle_register(\"playercards/Tarotcard\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- context menu to manually fix rotation\nfunction onLoad()\n self.addContextMenuItem(\"Rotate Preview\", rotatePreview)\n self.addContextMenuItem(\"Rotate Card+Preview\", rotateSelfAndPreview)\nend\n\n-- rotates the alt_view_angle\nfunction rotatePreview()\n local angle = self.alt_view_angle\n if angle.y == 0 then\n angle.y = 180\n else\n angle.y = 0\n end\n self.alt_view_angle = angle\nend\n\n-- rotates this card and the preview\nfunction rotateSelfAndPreview()\n self.setRotationSmooth(self.getRotation() + Vector(0, 180, 0))\n rotatePreview()\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/Tarotcard\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- context menu to manually fix rotation\nfunction onLoad()\n self.addContextMenuItem(\"Rotate Preview\", rotatePreview)\n self.addContextMenuItem(\"Rotate Card+Preview\", rotateSelfAndPreview)\nend\n\n-- rotates the alt_view_angle\nfunction rotatePreview()\n local angle = self.alt_view_angle\n if angle.y == 0 then\n angle.y = 180\n else\n angle.y = 0\n end\n self.alt_view_angle = angle\nend\n\n-- rotates this card and the preview\nfunction rotateSelfAndPreview()\n self.setRotationSmooth(self.getRotation() + Vector(0, 180, 0))\n rotatePreview()\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/Tarotcard\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -22770,7 +22780,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/Tarotcard\")\nend)\n__bundle_register(\"playercards/Tarotcard\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- context menu to manually fix rotation\nfunction onLoad()\n self.addContextMenuItem(\"Rotate Preview\", rotatePreview)\n self.addContextMenuItem(\"Rotate Card+Preview\", rotateSelfAndPreview)\nend\n\n-- rotates the alt_view_angle\nfunction rotatePreview()\n local angle = self.alt_view_angle\n if angle.y == 0 then\n angle.y = 180\n else\n angle.y = 0\n end\n self.alt_view_angle = angle\nend\n\n-- rotates this card and the preview\nfunction rotateSelfAndPreview()\n self.setRotationSmooth(self.getRotation() + Vector(0, 180, 0))\n rotatePreview()\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/Tarotcard\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- context menu to manually fix rotation\nfunction onLoad()\n self.addContextMenuItem(\"Rotate Preview\", rotatePreview)\n self.addContextMenuItem(\"Rotate Card+Preview\", rotateSelfAndPreview)\nend\n\n-- rotates the alt_view_angle\nfunction rotatePreview()\n local angle = self.alt_view_angle\n if angle.y == 0 then\n angle.y = 180\n else\n angle.y = 0\n end\n self.alt_view_angle = angle\nend\n\n-- rotates this card and the preview\nfunction rotateSelfAndPreview()\n self.setRotationSmooth(self.getRotation() + Vector(0, 180, 0))\n rotatePreview()\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/Tarotcard\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -23408,7 +23418,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/Tarotcard\")\nend)\n__bundle_register(\"playercards/Tarotcard\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- context menu to manually fix rotation\nfunction onLoad()\n self.addContextMenuItem(\"Rotate Preview\", rotatePreview)\n self.addContextMenuItem(\"Rotate Card+Preview\", rotateSelfAndPreview)\nend\n\n-- rotates the alt_view_angle\nfunction rotatePreview()\n local angle = self.alt_view_angle\n if angle.y == 0 then\n angle.y = 180\n else\n angle.y = 0\n end\n self.alt_view_angle = angle\nend\n\n-- rotates this card and the preview\nfunction rotateSelfAndPreview()\n self.setRotationSmooth(self.getRotation() + Vector(0, 180, 0))\n rotatePreview()\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/Tarotcard\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- context menu to manually fix rotation\nfunction onLoad()\n self.addContextMenuItem(\"Rotate Preview\", rotatePreview)\n self.addContextMenuItem(\"Rotate Card+Preview\", rotateSelfAndPreview)\nend\n\n-- rotates the alt_view_angle\nfunction rotatePreview()\n local angle = self.alt_view_angle\n if angle.y == 0 then\n angle.y = 180\n else\n angle.y = 0\n end\n self.alt_view_angle = angle\nend\n\n-- rotates this card and the preview\nfunction rotateSelfAndPreview()\n self.setRotationSmooth(self.getRotation() + Vector(0, 180, 0))\n rotatePreview()\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/Tarotcard\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -23582,7 +23592,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/Tarotcard\")\nend)\n__bundle_register(\"playercards/Tarotcard\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- context menu to manually fix rotation\nfunction onLoad()\n self.addContextMenuItem(\"Rotate Preview\", rotatePreview)\n self.addContextMenuItem(\"Rotate Card+Preview\", rotateSelfAndPreview)\nend\n\n-- rotates the alt_view_angle\nfunction rotatePreview()\n local angle = self.alt_view_angle\n if angle.y == 0 then\n angle.y = 180\n else\n angle.y = 0\n end\n self.alt_view_angle = angle\nend\n\n-- rotates this card and the preview\nfunction rotateSelfAndPreview()\n self.setRotationSmooth(self.getRotation() + Vector(0, 180, 0))\n rotatePreview()\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/Tarotcard\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- context menu to manually fix rotation\nfunction onLoad()\n self.addContextMenuItem(\"Rotate Preview\", rotatePreview)\n self.addContextMenuItem(\"Rotate Card+Preview\", rotateSelfAndPreview)\nend\n\n-- rotates the alt_view_angle\nfunction rotatePreview()\n local angle = self.alt_view_angle\n if angle.y == 0 then\n angle.y = 180\n else\n angle.y = 0\n end\n self.alt_view_angle = angle\nend\n\n-- rotates this card and the preview\nfunction rotateSelfAndPreview()\n self.setRotationSmooth(self.getRotation() + Vector(0, 180, 0))\n rotatePreview()\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/Tarotcard\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -47832,7 +47842,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/Subject5U-21Helper\")\nend)\n__bundle_register(\"accessories/Subject5U-21Helper\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal searchLib = require(\"util/SearchLib\")\n\nlocal classOrder = {\n \"Guardian\",\n \"Seeker\",\n \"Survivor\",\n \"Mystic\",\n \"Rogue\"\n}\n\nlocal bParam = {}\nbParam.width = 0\nbParam.height = 0\nbParam.function_owner = self\nbParam.click_function = \"none\"\nbParam.label = \"0\"\nbParam.position = {x = 0, y = 0.1, z = -0.7}\nbParam.scale = {x = 0.1, y = 0.1, z = 0.1}\nbParam.font_color = \"White\"\nbParam.font_size = 700\n\nfunction onLoad()\n self.createButton({\n width = 2750,\n height = 800,\n function_owner = self,\n click_function = \"updateDisplayButtons\",\n label = \"Update!\",\n tooltip = \"Count classes from cards on this tile\",\n position = {x = 0, y = 0.1, z = 0.875},\n scale = {x = 0.1, y = 0.1, z = 0.1},\n font_size = 500\n })\n createDisplayButtons()\nend\n\nfunction createDisplayButtons()\n local x_offset = 0.361\n bParam.position.x = -3 * x_offset\n for i = 1, 5 do\n bParam.position.x = bParam.position.x + x_offset\n self.createButton(bParam)\n end\nend\n\nfunction updateDisplayButtons(_, playerColor)\n local classCount = {\n Guardian = 0,\n Seeker = 0,\n Survivor = 0,\n Mystic = 0,\n Rogue = 0,\n uncounted = 0\n }\n\n -- loop through cards on this helper and count classes from metadata\n for _, notes in ipairs(getNotesFromCardsAndContainers()) do\n if notes.class then\n for str in string.gmatch(notes.class, \"([^|]+)\") do\n if not tonumber(classCount[str]) then\n str = \"uncounted\"\n end\n classCount[str] = classCount[str] + 1\n end\n end\n end\n\n -- edit button labels with index 1-5\n for i = 1, 5 do\n self.editButton({index = i, label = classCount[classOrder[i]]})\n end\n \n -- show message about uncounted cards\n if classCount.uncounted \u003e 0 then\n printToColor(\"Search included \" .. classCount.uncounted .. \" neutral/ununcounted card(s).\", playerColor, \"Orange\")\n end\nend\n\nfunction getNotesFromCardsAndContainers()\n local notesList = {}\n for _, obj in ipairs(searchLib.onObject(self)) do\n local notes = {}\n if obj.type == \"Card\" then\n notes = JSON.decode(obj.getGMNotes()) or {}\n table.insert(notesList, notes)\n elseif obj.type == \"Bag\" or obj.type == \"Deck\" then\n -- check if there are actually objects contained and loop through them\n local containedObjects = obj.getData().ContainedObjects\n if containedObjects then\n for _, deepObj in ipairs(containedObjects) do\n if deepObj.Name == \"Card\" or deepObj.Name == \"CardCustom\" then\n notes = JSON.decode(deepObj.GMNotes) or {}\n table.insert(notesList, notes)\n end\n end\n end\n end\n end\n return notesList\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"accessories/Subject5U-21Helper\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal searchLib = require(\"util/SearchLib\")\n\nlocal classOrder = {\n \"Guardian\",\n \"Seeker\",\n \"Survivor\",\n \"Mystic\",\n \"Rogue\"\n}\n\nlocal bParam = {}\nbParam.width = 0\nbParam.height = 0\nbParam.function_owner = self\nbParam.click_function = \"none\"\nbParam.label = \"0\"\nbParam.position = {x = 0, y = 0.1, z = -0.7}\nbParam.scale = {x = 0.1, y = 0.1, z = 0.1}\nbParam.font_color = \"White\"\nbParam.font_size = 700\n\nfunction onLoad()\n self.createButton({\n width = 2750,\n height = 800,\n function_owner = self,\n click_function = \"updateDisplayButtons\",\n label = \"Update!\",\n tooltip = \"Count classes from cards on this tile\",\n position = {x = 0, y = 0.1, z = 0.875},\n scale = {x = 0.1, y = 0.1, z = 0.1},\n font_size = 500\n })\n createDisplayButtons()\nend\n\nfunction createDisplayButtons()\n local x_offset = 0.361\n bParam.position.x = -3 * x_offset\n for i = 1, 5 do\n bParam.position.x = bParam.position.x + x_offset\n self.createButton(bParam)\n end\nend\n\nfunction updateDisplayButtons(_, playerColor)\n local classCount = {\n Guardian = 0,\n Seeker = 0,\n Survivor = 0,\n Mystic = 0,\n Rogue = 0,\n uncounted = 0\n }\n\n -- loop through cards on this helper and count classes from metadata\n for _, notes in ipairs(getNotesFromCardsAndContainers()) do\n if notes.class then\n for str in string.gmatch(notes.class, \"([^|]+)\") do\n if not tonumber(classCount[str]) then\n str = \"uncounted\"\n end\n classCount[str] = classCount[str] + 1\n end\n end\n end\n\n -- edit button labels with index 1-5\n for i = 1, 5 do\n self.editButton({index = i, label = classCount[classOrder[i]]})\n end\n \n -- show message about uncounted cards\n if classCount.uncounted \u003e 0 then\n printToColor(\"Search included \" .. classCount.uncounted .. \" neutral/ununcounted card(s).\", playerColor, \"Orange\")\n end\nend\n\nfunction getNotesFromCardsAndContainers()\n local notesList = {}\n for _, obj in ipairs(searchLib.onObject(self)) do\n local notes = {}\n if obj.type == \"Card\" then\n notes = JSON.decode(obj.getGMNotes()) or {}\n table.insert(notesList, notes)\n elseif obj.type == \"Bag\" or obj.type == \"Deck\" then\n -- check if there are actually objects contained and loop through them\n local containedObjects = obj.getData().ContainedObjects\n if containedObjects then\n for _, deepObj in ipairs(containedObjects) do\n if deepObj.Name == \"Card\" or deepObj.Name == \"CardCustom\" then\n notes = JSON.decode(deepObj.GMNotes) or {}\n table.insert(notesList, notes)\n end\n end\n end\n end\n end\n return notesList\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/Subject5U-21Helper\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Tile", @@ -47892,7 +47902,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "0", "MeasureMovement": false, "Name": "Custom_Tile", @@ -47949,7 +47959,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "0", "MeasureMovement": false, "Name": "Custom_Tile", @@ -48006,7 +48016,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Additional Victory Point Card\nlocal victoryDisplayApi = require(\"core/VictoryDisplayApi\")\n\nlocal MIN_VALUE = -10\nlocal MAX_VALUE = 99\nlocal vp, notes\n\nfunction onSave()\n return JSON.encode({ vp = vp, notes = notes })\nend\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n vp = loadedData.vp\n notes = loadedData.notes\n else\n vp = 1\n notes = \"Click to type\"\n end\n\n createButtons()\n createTextbox()\nend\n\nfunction createButtons()\n self.createButton({\n label = tostring(vp),\n click_function = \"click_function\",\n function_owner = self,\n position = { 0, 1, -0.05 },\n height = 600,\n width = 1000,\n font_size = 1000,\n font_color = { 0, 0, 0, 100 },\n color = { 0, 0, 0, 0 },\n scale = { 0.25, 0.25, 0.25 }\n })\nend\n\nfunction createTextbox()\n self.createInput({\n input_function = \"input_function\",\n function_owner = self,\n label = \"Click to type\",\n value = notes,\n alignment = 2,\n position = { x = 0, y = 1, z = 0.825 },\n width = 4250,\n height = 2250,\n font_size = 360,\n scale = { 0.2, 0.2, 0.2 }\n })\nend\n\nfunction updateNotes()\n local md = JSON.decode(self.getGMNotes())\n md.victory = vp\n self.setGMNotes(JSON.encode(md))\n victoryDisplayApi.update()\nend\n\nfunction updateSave()\n self.script_state = JSON.encode({ vp = vp, notes = notes })\nend\n\nfunction input_function(_, _, inputValue, selected)\n if selected == false then\n notes = inputValue\n updateSave()\n end\nend\n\nfunction click_function(_, _, isRightClick)\n vp = math.min(math.max(vp + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(vp) })\n updateSave()\n updateNotes()\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/VictoryDisplayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local VictoryDisplayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getVictoryDisplay()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"VictoryDisplay\")\n end\n\n -- triggers an update of the victory count\n ---@param delay? number Delay in seconds after which the update call is executed\n VictoryDisplayApi.update = function(delay)\n getVictoryDisplay().call(\"startUpdate\", delay)\n end\n\n -- moves a card to the victory display (in the first empty spot)\n ---@param object tts__Object Object that should be checked and potentially moved\n VictoryDisplayApi.placeCard = function(object)\n if object ~= nil and object.tag == \"Card\" then\n getVictoryDisplay().call(\"placeCard\", object)\n end\n end\n\n return VictoryDisplayApi\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Additional Victory Point Card\nlocal victoryDisplayApi = require(\"core/VictoryDisplayApi\")\n\nlocal MIN_VALUE = -10\nlocal MAX_VALUE = 99\nlocal vp, notes\n\nfunction onSave()\n return JSON.encode({ vp = vp, notes = notes })\nend\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n vp = loadedData.vp\n notes = loadedData.notes\n else\n vp = 1\n notes = \"Click to type\"\n end\n\n createButtons()\n createTextbox()\nend\n\nfunction createButtons()\n self.createButton({\n label = tostring(vp),\n click_function = \"click_function\",\n function_owner = self,\n position = { 0, 1, -0.05 },\n height = 600,\n width = 1000,\n font_size = 1000,\n font_color = { 0, 0, 0, 100 },\n color = { 0, 0, 0, 0 },\n scale = { 0.25, 0.25, 0.25 }\n })\nend\n\nfunction createTextbox()\n self.createInput({\n input_function = \"input_function\",\n function_owner = self,\n label = \"Click to type\",\n value = notes,\n alignment = 2,\n position = { x = 0, y = 1, z = 0.825 },\n width = 4250,\n height = 2250,\n font_size = 360,\n scale = { 0.2, 0.2, 0.2 }\n })\nend\n\nfunction updateNotes()\n local md = JSON.decode(self.getGMNotes())\n md.victory = vp\n self.setGMNotes(JSON.encode(md))\n victoryDisplayApi.update()\nend\n\nfunction updateSave()\n self.script_state = JSON.encode({ vp = vp, notes = notes })\nend\n\nfunction input_function(_, _, inputValue, selected)\n if selected == false then\n notes = inputValue\n updateSave()\n end\nend\n\nfunction click_function(_, _, isRightClick)\n vp = math.min(math.max(vp + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(vp) })\n updateSave()\n updateNotes()\nend\nend)\n__bundle_register(\"core/VictoryDisplayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local VictoryDisplayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getVictoryDisplay()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"VictoryDisplay\")\n end\n\n -- triggers an update of the victory count\n ---@param delay? number Delay in seconds after which the update call is executed\n VictoryDisplayApi.update = function(delay)\n getVictoryDisplay().call(\"startUpdate\", delay)\n end\n\n -- moves a card to the victory display (in the first empty spot)\n ---@param object tts__Object Object that should be checked and potentially moved\n VictoryDisplayApi.placeCard = function(object)\n if object ~= nil and object.tag == \"Card\" then\n getVictoryDisplay().call(\"placeCard\", object)\n end\n end\n\n return VictoryDisplayApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "{\"notes\":\"Click to type\",\"vp\":1}", "MeasureMovement": false, "Name": "CardCustom", @@ -48132,7 +48142,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "{\"ml\":[]}", "MeasureMovement": false, "Name": "Custom_Model", @@ -48201,7 +48211,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -48270,7 +48280,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -48339,7 +48349,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -48408,7 +48418,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -48477,7 +48487,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -48546,7 +48556,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -48615,7 +48625,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -48684,7 +48694,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -48753,7 +48763,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -49857,7 +49867,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"chaosbag/BlessCurseManager\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\n-- common button parameters\nlocal buttonParamaters = {}\nbuttonParamaters.function_owner = self\nbuttonParamaters.color = { 0, 0, 0, 0 }\nbuttonParamaters.width = 700\nbuttonParamaters.height = 700\n\nlocal updating\n\n---------------------------------------------------------\n-- creating buttons and menus + initializing tables\n---------------------------------------------------------\n\nfunction onLoad()\n -- index: 0 - bless\n buttonParamaters.click_function = \"clickBless\"\n buttonParamaters.position = { -1.03, 0, 0.46 }\n buttonParamaters.tooltip = \"Add / Remove Bless\"\n self.createButton(buttonParamaters)\n\n -- index: 1 - curse\n buttonParamaters.click_function = \"clickCurse\"\n buttonParamaters.position[1] = -buttonParamaters.position[1]\n buttonParamaters.tooltip = \"Add / Remove Curse\"\n self.createButton(buttonParamaters)\n\n -- index: 2 - bless count\n buttonParamaters.tooltip = \"\"\n buttonParamaters.click_function = \"none\"\n buttonParamaters.width = 0\n buttonParamaters.height = 0\n buttonParamaters.color = { 0.4, 0.4, 0.4 }\n buttonParamaters.font_color = { 1, 1, 1 }\n buttonParamaters.font_size = 235\n buttonParamaters.position = { -1.03, 0.06, -0.8 }\n self.createButton(buttonParamaters)\n\n -- index: 3 - curse count\n buttonParamaters.position[1] = -buttonParamaters.position[1]\n self.createButton(buttonParamaters)\n\n -- context menu\n self.addContextMenuItem(\"Remove all\", doRemove)\n self.addContextMenuItem(\"Reset\", doReset)\n\n -- initializing tables\n initializeState()\n broadcastCount(\"Curse\")\n broadcastCount(\"Bless\")\nend\n\nfunction resetTables()\n numInPlay = { Bless = 0, Curse = 0 }\n tokensTaken = { Bless = {}, Curse = {} }\n sealedTokens = {}\nend\n\nfunction initializeState()\n resetTables()\n\n -- count tokens in the bag\n local chaosBag = chaosBagApi.findChaosBag()\n for _, v in ipairs(chaosBag.getObjects()) do\n if v.name == \"Bless\" then\n numInPlay.Bless = numInPlay.Bless + 1\n elseif v.name == \"Curse\" then\n numInPlay.Curse = numInPlay.Curse + 1\n end\n end\n\n -- find tokens in the play area\n for _, obj in ipairs(getObjects()) do\n local pos = obj.getPosition()\n if obj.hasTag(\"tempToken\") then\n -- skip the tokens from the Token Arranger\n elseif pos.x \u003e -65 and pos.x \u003c 10 and pos.z \u003e -35 and pos.z \u003c 35 and obj.type == \"Tile\" then\n if obj.getName() == \"Bless\" then\n table.insert(tokensTaken.Bless, obj.getGUID())\n numInPlay.Bless = numInPlay.Bless + 1\n elseif obj.getName() == \"Curse\" then\n table.insert(tokensTaken.Curse, obj.getGUID())\n numInPlay.Curse = numInPlay.Curse + 1\n end\n end\n end\n\n updateButtonLabels()\nend\n\nfunction updateButtonLabels()\n self.editButton({ index = 2, label = formatTokenCount(\"Bless\", true)})\n self.editButton({ index = 3, label = formatTokenCount(\"Curse\", true)})\nend\n\nfunction broadcastCount(token)\n local count = formatTokenCount(token)\n if count == \"(0 + 0)\" then return end\n broadcastToAll(token .. \" Tokens \" .. count, \"White\")\nend\n\nfunction broadcastStatus(color)\n broadcastToColor(\"Curse Tokens \" .. formatTokenCount(\"Curse\"), color, \"White\")\n broadcastToColor(\"Bless Tokens \" .. formatTokenCount(\"Bless\"), color, \"White\")\nend\n\n---------------------------------------------------------\n-- TTS event handling\n---------------------------------------------------------\n\n-- enable tracking of bag changes for 1 second\nfunction onObjectDrop(_, object)\n if not isBlurseToken(object) then return end\n\n -- check if object was dropped in chaos bag area\n for _, zone in ipairs(object.getZones()) do\n if zone.getName() == \"ChaosBagZone\" then\n trackBagChange = true\n Wait.time(function() trackBagChange = false end, 1)\n return\n end\n end\nend\n\n-- handle manual returning of bless / curse tokens\nfunction onObjectEnterContainer(container, object)\n if not (trackBagChange and isChaosbag(container) and isBlurseToken(object)) then return end\n\n -- small delay to ensure token has entered bag\n Wait.time(doReset, 0.5)\nend\n\nfunction isChaosbag(obj)\n if obj.getDescription() ~= \"Chaos Bag\" then return end -- early exit for performance\n return obj == chaosBagApi.findChaosBag()\nend\n\nfunction isBlurseToken(obj)\n local name = obj.getName()\n return name == \"Bless\" or name == \"Curse\"\nend\n\n---------------------------------------------------------\n-- context menu functions\n---------------------------------------------------------\n\nfunction doRemove(color)\n local chaosBag = chaosBagApi.findChaosBag()\n\n -- remove tokens from chaos bag\n local count = { Bless = 0, Curse = 0 }\n for _, v in ipairs(chaosBag.getObjects()) do\n if v.name == \"Bless\" or v.name == \"Curse\" then\n chaosBag.takeObject({\n guid = v.guid,\n position = { 0, 5, 0 },\n callback_function = function(obj) obj.destruct() end\n })\n count[v.name] = count[v.name] + 1\n end\n end\n\n broadcastToColor(\"Removed \" .. count.Bless .. \" Bless and \" .. count.Curse .. \" Curse tokens from the chaos bag.\", color, \"White\")\n broadcastToColor(\"Removed \" .. removeTakenTokens(\"Bless\") .. \" Bless and \" .. removeTakenTokens(\"Curse\") .. \" Curse tokens from play.\", color, \"White\")\n\n resetTables()\n updateButtonLabels()\n tokenArrangerApi.layout()\nend\n\nfunction doReset()\n initializeState()\n broadcastCount(\"Curse\")\n broadcastCount(\"Bless\")\n tokenArrangerApi.layout()\nend\n\n---------------------------------------------------------\n-- click functions\n---------------------------------------------------------\n\nfunction clickBless(_, color, isRightClick)\n playerColor = color\n callFunctions(\"Bless\", isRightClick)\nend\n\nfunction clickCurse(_, color, isRightClick)\n playerColor = color\n callFunctions(\"Curse\", isRightClick)\nend\n\nfunction callFunctions(type, isRightClick)\n if not chaosBagApi.canTouchChaosTokens() then return end\n\n if isRightClick then\n removeToken(type)\n else\n addToken(type)\n end\n\n tokenArrangerApi.layout()\nend\n\n---------------------------------------------------------\n-- called functions\n---------------------------------------------------------\n\n-- returns a formatted string with information about the provided token type (bless / curse)\n---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n---@param omitBrackets? boolean Controls whether the brackets should be omitted from the return\n---@return string tokenCount\nfunction formatTokenCount(type, omitBrackets)\n if omitBrackets then\n return (numInPlay[type] - #tokensTaken[type]) .. \" + \" .. #tokensTaken[type]\n else\n return \"(\" .. (numInPlay[type] - #tokensTaken[type]) .. \" + \" .. #tokensTaken[type] .. \")\"\n end\nend\n\n-- seals a token on a card (called by cards that seal bless/curse tokens)\n---@param param table This contains the type and guid of the sealed token\nfunction sealedToken(param)\n table.insert(tokensTaken[param.type], param.guid)\n broadcastCount(param.type)\n updateButtonLabels()\nend\n\n-- returns a token to the bag (called by cards that seal bless/curse tokens)\n---@param param table This contains the type and guid of the released token\nfunction releasedToken(param)\n for i, v in ipairs(tokensTaken[param.type]) do\n if v == param.guid then\n table.remove(tokensTaken[param.type], i)\n break\n end\n end\n updateDisplayAndBroadcast(param.type)\nend\n\n-- removes a token (called by cards that seal bless/curse tokens)\n---@param param table This contains the type and guid of the released token\nfunction returnedToken(param)\n for i, v in ipairs(tokensTaken[param.type]) do\n if v == param.guid then\n table.remove(tokensTaken[param.type], i)\n numInPlay[param.type] = numInPlay[param.type] - 1\n break\n end\n end\n updateDisplayAndBroadcast(param.type)\nend\n\nfunction updateDisplayAndBroadcast(type)\n if not updating then\n updating = true\n Wait.frames(function()\n broadcastCount(type)\n updateButtonLabels()\n updating = false\n end, 5)\n end\nend\n\n---------------------------------------------------------\n-- main functions: add and remove\n---------------------------------------------------------\n\nfunction addToken(type)\n if numInPlay[type] == 10 then\n printToColor(\"10 tokens already in play, not adding any.\", playerColor)\n return\n end\n numInPlay[type] = numInPlay[type] + 1\n printToAll(\"Adding \" .. type .. \" token \" .. formatTokenCount(type))\n updateButtonLabels()\n return chaosBagApi.spawnChaosToken(type)\nend\n\nfunction removeToken(type)\n local chaosBag = chaosBagApi.findChaosBag()\n local tokens = {}\n\n for _, v in ipairs(chaosBag.getObjects()) do\n if v.name == type then\n table.insert(tokens, v.guid)\n end\n end\n\n if #tokens == 0 then\n printToColor(\"No \" .. type .. \" tokens in the chaos bag.\", playerColor)\n return\n end\n\n chaosBag.takeObject({\n guid = table.remove(tokens),\n smooth = false,\n callback_function = function(obj)\n numInPlay[type] = numInPlay[type] - 1\n printToAll(\"Removing \" .. type .. \" token \" .. formatTokenCount(type))\n updateButtonLabels()\n obj.destruct()\n end\n })\nend\n\n-- removing tokens that were 'taken'\nfunction removeTakenTokens(type)\n local count = 0\n for _, guid in ipairs(tokensTaken[type]) do\n local token = getObjectFromGUID(guid)\n if token ~= nil then\n token.destruct()\n count = count + 1\n end\n end\n return count\nend\n\n---------------------------------------------------------\n-- Wendy's Menu (context menu for cards on hotkey press)\n---------------------------------------------------------\n\nfunction addMenuOptions(parameters)\n local playerColor = parameters.playerColor\n local hoveredObject = parameters.hoveredObject\n if hoveredObject == nil or hoveredObject.type ~= \"Card\" then\n broadcastToColor(\"Right-click seal options can only be added to cards.\", playerColor)\n return\n elseif hoveredObject.hasTag(\"CardThatSeals\") or hoveredObject.getVar(\"MENU_ADDED\") == true then\n broadcastToColor(\"This card already has a sealing context menu.\", playerColor)\n return\n end\n\n hoveredObject.addContextMenuItem(\"Seal Bless\", function(color)\n sealToken(\"Bless\", color, hoveredObject)\n tokenArrangerApi.layout()\n end, true)\n\n hoveredObject.addContextMenuItem(\"Release Bless\", function(color)\n releaseToken(\"Bless\", color, hoveredObject)\n tokenArrangerApi.layout()\n end, true)\n\n hoveredObject.addContextMenuItem(\"Seal Curse\", function(color)\n sealToken(\"Curse\", color, hoveredObject)\n tokenArrangerApi.layout()\n end, true)\n\n hoveredObject.addContextMenuItem(\"Release Curse\", function(color)\n releaseToken(\"Curse\", color, hoveredObject)\n tokenArrangerApi.layout()\n end, true)\n\n broadcastToColor(\"Right-click seal options added to \" .. hoveredObject.getName(), playerColor)\n hoveredObject.setVar(\"MENU_ADDED\", true)\n sealedTokens[hoveredObject.getGUID()] = {}\nend\n\nfunction sealToken(type, playerColor, hoveredObject)\n local chaosBag = chaosBagApi.findChaosBag()\n\n for i, token in ipairs(chaosBag.getObjects()) do\n if token.name == type then\n return chaosBag.takeObject({\n position = hoveredObject.getPosition() + Vector(0, 1, 0),\n index = i - 1,\n smooth = false,\n callback_function = function(obj)\n table.insert(sealedTokens[hoveredObject.getGUID()], obj)\n table.insert(tokensTaken[type], obj.getGUID())\n tokenArrangerApi.layout()\n updateDisplayAndBroadcast(type)\n end\n })\n end\n end\n printToColor(type .. \" token not found in bag\", playerColor)\nend\n\nfunction releaseToken(type, playerColor, hoveredObject)\n local chaosBag = chaosBagApi.findChaosBag()\n local tokens = sealedTokens[hoveredObject.getGUID()]\n if tokens == nil or #tokens == 0 then return end\n\n for i, token in ipairs(tokens) do\n if token ~= nil and token.getName() == type then\n local guid = token.getGUID()\n chaosBag.putObject(token)\n for j, v in ipairs(tokensTaken[type]) do\n if v == guid then\n table.remove(tokensTaken[type], j)\n table.remove(tokens, i)\n tokenArrangerApi.layout()\n updateDisplayAndBroadcast(type)\n return\n end\n end\n end\n end\n printToColor(type .. \" token not sealed on \" .. hoveredObject.getName(), playerColor)\nend\n\nfunction none() end\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"chaosbag/BlessCurseManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\n-- common button parameters\nlocal buttonParamaters = {}\nbuttonParamaters.function_owner = self\nbuttonParamaters.color = { 0, 0, 0, 0 }\nbuttonParamaters.width = 700\nbuttonParamaters.height = 700\n\nlocal updating\n\n---------------------------------------------------------\n-- creating buttons and menus + initializing tables\n---------------------------------------------------------\n\nfunction onLoad()\n -- index: 0 - bless\n buttonParamaters.click_function = \"clickBless\"\n buttonParamaters.position = { -1.03, 0, 0.46 }\n buttonParamaters.tooltip = \"Add / Remove Bless\"\n self.createButton(buttonParamaters)\n\n -- index: 1 - curse\n buttonParamaters.click_function = \"clickCurse\"\n buttonParamaters.position[1] = -buttonParamaters.position[1]\n buttonParamaters.tooltip = \"Add / Remove Curse\"\n self.createButton(buttonParamaters)\n\n -- index: 2 - bless count\n buttonParamaters.tooltip = \"\"\n buttonParamaters.click_function = \"none\"\n buttonParamaters.width = 0\n buttonParamaters.height = 0\n buttonParamaters.color = { 0.4, 0.4, 0.4 }\n buttonParamaters.font_color = { 1, 1, 1 }\n buttonParamaters.font_size = 235\n buttonParamaters.position = { -1.03, 0.06, -0.8 }\n self.createButton(buttonParamaters)\n\n -- index: 3 - curse count\n buttonParamaters.position[1] = -buttonParamaters.position[1]\n self.createButton(buttonParamaters)\n\n -- context menu\n self.addContextMenuItem(\"Remove all\", doRemove)\n self.addContextMenuItem(\"Reset\", doReset)\n\n -- initializing tables\n initializeState()\n broadcastCount(\"Curse\")\n broadcastCount(\"Bless\")\nend\n\nfunction resetTables()\n numInPlay = { Bless = 0, Curse = 0 }\n tokensTaken = { Bless = {}, Curse = {} }\n sealedTokens = {}\nend\n\nfunction initializeState()\n resetTables()\n\n -- count tokens in the bag\n local chaosBag = chaosBagApi.findChaosBag()\n for _, v in ipairs(chaosBag.getObjects()) do\n if v.name == \"Bless\" then\n numInPlay.Bless = numInPlay.Bless + 1\n elseif v.name == \"Curse\" then\n numInPlay.Curse = numInPlay.Curse + 1\n end\n end\n\n -- find tokens in the play area\n for _, obj in ipairs(getObjects()) do\n local pos = obj.getPosition()\n if obj.hasTag(\"tempToken\") then\n -- skip the tokens from the Token Arranger\n elseif pos.x \u003e -65 and pos.x \u003c 10 and pos.z \u003e -35 and pos.z \u003c 35 and obj.type == \"Tile\" then\n if obj.getName() == \"Bless\" then\n table.insert(tokensTaken.Bless, obj.getGUID())\n numInPlay.Bless = numInPlay.Bless + 1\n elseif obj.getName() == \"Curse\" then\n table.insert(tokensTaken.Curse, obj.getGUID())\n numInPlay.Curse = numInPlay.Curse + 1\n end\n end\n end\n\n updateButtonLabels()\nend\n\nfunction updateButtonLabels()\n self.editButton({ index = 2, label = formatTokenCount(\"Bless\", true)})\n self.editButton({ index = 3, label = formatTokenCount(\"Curse\", true)})\nend\n\nfunction broadcastCount(token)\n local count = formatTokenCount(token)\n if count == \"(0 + 0)\" then return end\n broadcastToAll(token .. \" Tokens \" .. count, \"White\")\nend\n\nfunction broadcastStatus(color)\n broadcastToColor(\"Curse Tokens \" .. formatTokenCount(\"Curse\"), color, \"White\")\n broadcastToColor(\"Bless Tokens \" .. formatTokenCount(\"Bless\"), color, \"White\")\nend\n\n---------------------------------------------------------\n-- TTS event handling\n---------------------------------------------------------\n\n-- enable tracking of bag changes for 1 second\nfunction onObjectDrop(_, object)\n if not isBlurseToken(object) then return end\n\n -- check if object was dropped in chaos bag area\n for _, zone in ipairs(object.getZones()) do\n if zone.getName() == \"ChaosBagZone\" then\n trackBagChange = true\n Wait.time(function() trackBagChange = false end, 1)\n return\n end\n end\nend\n\n-- handle manual returning of bless / curse tokens\nfunction onObjectEnterContainer(container, object)\n if not (trackBagChange and isChaosbag(container) and isBlurseToken(object)) then return end\n\n -- small delay to ensure token has entered bag\n Wait.time(doReset, 0.5)\nend\n\nfunction isChaosbag(obj)\n if obj.getDescription() ~= \"Chaos Bag\" then return end -- early exit for performance\n return obj == chaosBagApi.findChaosBag()\nend\n\nfunction isBlurseToken(obj)\n local name = obj.getName()\n return name == \"Bless\" or name == \"Curse\"\nend\n\n---------------------------------------------------------\n-- context menu functions\n---------------------------------------------------------\n\nfunction doRemove(color)\n local chaosBag = chaosBagApi.findChaosBag()\n\n -- remove tokens from chaos bag\n local count = { Bless = 0, Curse = 0 }\n for _, v in ipairs(chaosBag.getObjects()) do\n if v.name == \"Bless\" or v.name == \"Curse\" then\n chaosBag.takeObject({\n guid = v.guid,\n position = { 0, 5, 0 },\n callback_function = function(obj) obj.destruct() end\n })\n count[v.name] = count[v.name] + 1\n end\n end\n\n broadcastToColor(\"Removed \" .. count.Bless .. \" Bless and \" .. count.Curse .. \" Curse tokens from the chaos bag.\", color, \"White\")\n broadcastToColor(\"Removed \" .. removeTakenTokens(\"Bless\") .. \" Bless and \" .. removeTakenTokens(\"Curse\") .. \" Curse tokens from play.\", color, \"White\")\n\n resetTables()\n updateButtonLabels()\n tokenArrangerApi.layout()\nend\n\nfunction doReset()\n initializeState()\n broadcastCount(\"Curse\")\n broadcastCount(\"Bless\")\n tokenArrangerApi.layout()\nend\n\n---------------------------------------------------------\n-- click functions\n---------------------------------------------------------\n\nfunction clickBless(_, color, isRightClick)\n playerColor = color\n callFunctions(\"Bless\", isRightClick)\nend\n\nfunction clickCurse(_, color, isRightClick)\n playerColor = color\n callFunctions(\"Curse\", isRightClick)\nend\n\nfunction callFunctions(type, isRightClick)\n if not chaosBagApi.canTouchChaosTokens() then return end\n\n if isRightClick then\n removeToken(type)\n else\n addToken(type)\n end\n\n tokenArrangerApi.layout()\nend\n\n---------------------------------------------------------\n-- called functions\n---------------------------------------------------------\n\n-- returns a formatted string with information about the provided token type (bless / curse)\n---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n---@param omitBrackets? boolean Controls whether the brackets should be omitted from the return\n---@return string tokenCount\nfunction formatTokenCount(type, omitBrackets)\n if omitBrackets then\n return (numInPlay[type] - #tokensTaken[type]) .. \" + \" .. #tokensTaken[type]\n else\n return \"(\" .. (numInPlay[type] - #tokensTaken[type]) .. \" + \" .. #tokensTaken[type] .. \")\"\n end\nend\n\n-- seals a token on a card (called by cards that seal bless/curse tokens)\n---@param param table This contains the type and guid of the sealed token\nfunction sealedToken(param)\n table.insert(tokensTaken[param.type], param.guid)\n broadcastCount(param.type)\n updateButtonLabels()\nend\n\n-- returns a token to the bag (called by cards that seal bless/curse tokens)\n---@param param table This contains the type and guid of the released token\nfunction releasedToken(param)\n for i, v in ipairs(tokensTaken[param.type]) do\n if v == param.guid then\n table.remove(tokensTaken[param.type], i)\n break\n end\n end\n updateDisplayAndBroadcast(param.type)\nend\n\n-- removes a token (called by cards that seal bless/curse tokens)\n---@param param table This contains the type and guid of the released token\nfunction returnedToken(param)\n for i, v in ipairs(tokensTaken[param.type]) do\n if v == param.guid then\n table.remove(tokensTaken[param.type], i)\n numInPlay[param.type] = numInPlay[param.type] - 1\n break\n end\n end\n updateDisplayAndBroadcast(param.type)\nend\n\nfunction updateDisplayAndBroadcast(type)\n if not updating then\n updating = true\n Wait.frames(function()\n broadcastCount(type)\n updateButtonLabels()\n updating = false\n end, 5)\n end\nend\n\n---------------------------------------------------------\n-- main functions: add and remove\n---------------------------------------------------------\n\nfunction addToken(type)\n if numInPlay[type] == 10 then\n printToColor(\"10 tokens already in play, not adding any.\", playerColor)\n return\n end\n numInPlay[type] = numInPlay[type] + 1\n printToAll(\"Adding \" .. type .. \" token \" .. formatTokenCount(type))\n updateButtonLabels()\n return chaosBagApi.spawnChaosToken(type)\nend\n\nfunction removeToken(type)\n local chaosBag = chaosBagApi.findChaosBag()\n local tokens = {}\n\n for _, v in ipairs(chaosBag.getObjects()) do\n if v.name == type then\n table.insert(tokens, v.guid)\n end\n end\n\n if #tokens == 0 then\n printToColor(\"No \" .. type .. \" tokens in the chaos bag.\", playerColor)\n return\n end\n\n chaosBag.takeObject({\n guid = table.remove(tokens),\n smooth = false,\n callback_function = function(obj)\n numInPlay[type] = numInPlay[type] - 1\n printToAll(\"Removing \" .. type .. \" token \" .. formatTokenCount(type))\n updateButtonLabels()\n obj.destruct()\n end\n })\nend\n\n-- removing tokens that were 'taken'\nfunction removeTakenTokens(type)\n local count = 0\n for _, guid in ipairs(tokensTaken[type]) do\n local token = getObjectFromGUID(guid)\n if token ~= nil then\n token.destruct()\n count = count + 1\n end\n end\n return count\nend\n\n---------------------------------------------------------\n-- Wendy's Menu (context menu for cards on hotkey press)\n---------------------------------------------------------\n\nfunction addMenuOptions(parameters)\n local playerColor = parameters.playerColor\n local hoveredObject = parameters.hoveredObject\n if hoveredObject == nil or hoveredObject.type ~= \"Card\" then\n broadcastToColor(\"Right-click seal options can only be added to cards.\", playerColor)\n return\n elseif hoveredObject.hasTag(\"CardThatSeals\") or hoveredObject.getVar(\"MENU_ADDED\") == true then\n broadcastToColor(\"This card already has a sealing context menu.\", playerColor)\n return\n end\n\n hoveredObject.addContextMenuItem(\"Seal Bless\", function(color)\n sealToken(\"Bless\", color, hoveredObject)\n tokenArrangerApi.layout()\n end, true)\n\n hoveredObject.addContextMenuItem(\"Release Bless\", function(color)\n releaseToken(\"Bless\", color, hoveredObject)\n tokenArrangerApi.layout()\n end, true)\n\n hoveredObject.addContextMenuItem(\"Seal Curse\", function(color)\n sealToken(\"Curse\", color, hoveredObject)\n tokenArrangerApi.layout()\n end, true)\n\n hoveredObject.addContextMenuItem(\"Release Curse\", function(color)\n releaseToken(\"Curse\", color, hoveredObject)\n tokenArrangerApi.layout()\n end, true)\n\n broadcastToColor(\"Right-click seal options added to \" .. hoveredObject.getName(), playerColor)\n hoveredObject.setVar(\"MENU_ADDED\", true)\n sealedTokens[hoveredObject.getGUID()] = {}\nend\n\nfunction sealToken(type, playerColor, hoveredObject)\n local chaosBag = chaosBagApi.findChaosBag()\n\n for i, token in ipairs(chaosBag.getObjects()) do\n if token.name == type then\n return chaosBag.takeObject({\n position = hoveredObject.getPosition() + Vector(0, 1, 0),\n index = i - 1,\n smooth = false,\n callback_function = function(obj)\n table.insert(sealedTokens[hoveredObject.getGUID()], obj)\n table.insert(tokensTaken[type], obj.getGUID())\n tokenArrangerApi.layout()\n updateDisplayAndBroadcast(type)\n end\n })\n end\n end\n printToColor(type .. \" token not found in bag\", playerColor)\nend\n\nfunction releaseToken(type, playerColor, hoveredObject)\n local chaosBag = chaosBagApi.findChaosBag()\n local tokens = sealedTokens[hoveredObject.getGUID()]\n if tokens == nil or #tokens == 0 then return end\n\n for i, token in ipairs(tokens) do\n if token ~= nil and token.getName() == type then\n local guid = token.getGUID()\n chaosBag.putObject(token)\n for j, v in ipairs(tokensTaken[type]) do\n if v == guid then\n table.remove(tokensTaken[type], j)\n table.remove(tokens, i)\n tokenArrangerApi.layout()\n updateDisplayAndBroadcast(type)\n return\n end\n end\n end\n end\n printToColor(type .. \" token not sealed on \" .. hoveredObject.getName(), playerColor)\nend\n\nfunction none() end\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"chaosbag/BlessCurseManager\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "false", "MeasureMovement": false, "Name": "Custom_Token", @@ -50018,7 +50028,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -50087,7 +50097,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -50156,7 +50166,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -50225,7 +50235,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -50285,7 +50295,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DoomInPlayCounter\")\nend)\n__bundle_register(\"core/DoomInPlayCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nlocal ZONE, TRASH\nlocal doomURL = \"https://i.imgur.com/EoL7yaZ.png\"\nlocal IGNORE_TAG = \"DoomCounter_ignore\"\nlocal TOTAL_PLAY_AREA = {\n upperLeft = {\n x = -9,\n z = -35\n },\n lowerRight = {\n x = -60,\n z = 35\n }\n}\n\n-- create button, context menu and start loop\nfunction onLoad()\n self.createButton({\n label = \"0\",\n click_function = \"none\",\n function_owner = self,\n position = { 0, 0.06, 0 },\n height = 0,\n width = 0,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n TRASH = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"Trash\")\n ZONE = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayAreaZone\")\n Wait.time(updateCounter, 2, -1)\nend\n\n-- main function\nfunction updateCounter()\n local count = countDoomInPlay()\n self.editButton({ index = 0, label = tostring(count) })\nend\n\n-- get doom in play\nfunction countDoomInPlay()\n local count = 0\n\n for _, obj in ipairs(getObjects()) do\n count = count + getDoomAmount(obj)\n end\n\n return count\nend\n\n-- gets quantity (for stacks) of doom\nfunction getDoomAmount(obj)\n if (obj.is_face_down and obj.getCustomObject().image_bottom == doomURL)\n and not obj.hasTag(IGNORE_TAG)\n and inArea(obj.getPosition(), TOTAL_PLAY_AREA) then\n return math.abs(obj.getQuantity())\n else\n return 0\n end\nend\n\n-- removes doom from playermats / playarea\nfunction removeDoom(options)\n if options.Playermats then\n local count = removeDoomFromList(playmatApi.searchAroundPlaymat(\"All\"))\n if count \u003e 0 then \n broadcastToAll(count .. \" doom removed from playermats.\", \"White\")\n end\n end\n\n if options.Playarea then\n local count = removeDoomFromList(ZONE.getObjects())\n if count \u003e 0 then \n broadcastToAll(count .. \" doom removed from play area.\", \"White\")\n end\n end\nend\n\n-- removes doom from provided object list and returns the removed amount\nfunction removeDoomFromList(objList)\n local count = 0\n for _, obj in ipairs(objList) do\n local amount = getDoomAmount(obj)\n if amount \u003e 0 then\n TRASH.putObject(obj)\n count = count + amount\n end\n end\n return count\nend\n\n-- helper function to check if a position is inside an area\nfunction inArea(point, bounds)\n return (point.x \u003c bounds.upperLeft.x\n and point.x \u003e bounds.lowerRight.x\n and point.z \u003e bounds.upperLeft.z\n and point.z \u003c bounds.lowerRight.z)\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DoomInPlayCounter\")\nend)\n__bundle_register(\"core/DoomInPlayCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nlocal ZONE, TRASH\nlocal doomURL = \"https://i.imgur.com/EoL7yaZ.png\"\nlocal IGNORE_TAG = \"DoomCounter_ignore\"\nlocal TOTAL_PLAY_AREA = {\n upperLeft = {\n x = -9,\n z = -35\n },\n lowerRight = {\n x = -60,\n z = 35\n }\n}\n\n-- create button, context menu and start loop\nfunction onLoad()\n self.createButton({\n label = \"0\",\n click_function = \"none\",\n function_owner = self,\n position = { 0, 0.06, 0 },\n height = 0,\n width = 0,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n TRASH = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"Trash\")\n ZONE = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayAreaZone\")\n Wait.time(updateCounter, 2, -1)\nend\n\n-- main function\nfunction updateCounter()\n local count = countDoomInPlay()\n self.editButton({ index = 0, label = tostring(count) })\nend\n\n-- get doom in play\nfunction countDoomInPlay()\n local count = 0\n\n for _, obj in ipairs(getObjects()) do\n count = count + getDoomAmount(obj)\n end\n\n return count\nend\n\n-- gets quantity (for stacks) of doom\nfunction getDoomAmount(obj)\n if (obj.is_face_down and obj.getCustomObject().image_bottom == doomURL)\n and not obj.hasTag(IGNORE_TAG)\n and inArea(obj.getPosition(), TOTAL_PLAY_AREA) then\n return math.abs(obj.getQuantity())\n else\n return 0\n end\nend\n\n-- removes doom from playermats / playarea\nfunction removeDoom(options)\n if options.Playermats then\n local count = removeDoomFromList(playmatApi.searchAroundPlaymat(\"All\"))\n if count \u003e 0 then \n broadcastToAll(count .. \" doom removed from playermats.\", \"White\")\n end\n end\n\n if options.Playarea then\n local count = removeDoomFromList(ZONE.getObjects())\n if count \u003e 0 then \n broadcastToAll(count .. \" doom removed from play area.\", \"White\")\n end\n end\nend\n\n-- removes doom from provided object list and returns the removed amount\nfunction removeDoomFromList(objList)\n local count = 0\n for _, obj in ipairs(objList) do\n local amount = getDoomAmount(obj)\n if amount \u003e 0 then\n TRASH.putObject(obj)\n count = count + amount\n end\n end\n return count\nend\n\n-- helper function to check if a position is inside an area\nfunction inArea(point, bounds)\n return (point.x \u003c bounds.upperLeft.x\n and point.x \u003e bounds.lowerRight.x\n and point.z \u003e bounds.upperLeft.z\n and point.z \u003c bounds.lowerRight.z)\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Token", @@ -50369,9 +50379,9 @@ }, { "Position": { - "x": -0.631, + "x": 1.758, "y": 0.1, - "z": 0.551 + "z": 0.04 }, "Tags": [ "Asset" @@ -50379,39 +50389,9 @@ }, { "Position": { - "x": -0.616, - "y": 0.102, - "z": 0.024 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": -0.177, - "y": 0.101, - "z": 0.032 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": -0.174, - "y": 0.099, - "z": 0.551 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": 0.212, + "x": 1.371, "y": 0.1, - "z": 0.559 + "z": 0.038 }, "Tags": [ "Asset" @@ -50419,7 +50399,7 @@ }, { "Position": { - "x": 0.217, + "x": 0.98, "y": 0.1, "z": 0.035 }, @@ -50439,28 +50419,8 @@ }, { "Position": { - "x": 0.605, + "x": 0.217, "y": 0.1, - "z": 0.555 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": 0.977, - "y": 0.099, - "z": 0.556 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": 0.98, - "y": 0.099, "z": 0.035 }, "Tags": [ @@ -50469,9 +50429,9 @@ }, { "Position": { - "x": 1.371, + "x": -0.177, "y": 0.1, - "z": 0.038 + "z": 0.032 }, "Tags": [ "Asset" @@ -50479,9 +50439,9 @@ }, { "Position": { - "x": 1.371, - "y": 0.099, - "z": 0.558 + "x": -0.616, + "y": 0.1, + "z": 0.024 }, "Tags": [ "Asset" @@ -50499,9 +50459,59 @@ }, { "Position": { - "x": 1.758, - "y": 0.101, - "z": 0.04 + "x": 1.371, + "y": 0.1, + "z": 0.558 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": 0.977, + "y": 0.1, + "z": 0.556 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": 0.605, + "y": 0.1, + "z": 0.555 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": 0.212, + "y": 0.1, + "z": 0.559 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": -0.174, + "y": 0.1, + "z": 0.551 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": -0.631, + "y": 0.1, + "z": 0.551 }, "Tags": [ "Asset" @@ -50641,7 +50651,7 @@ }, "ImageScalar": 1, "ImageSecondaryURL": "", - "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037357630681963618/E7271737B19CE0BFAAA382BEEEF497FE3E06ECC1/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/", "WidthScale": 0 }, "Description": "", @@ -50655,8 +50665,8 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/Playmat\")\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat\n ---@param mat tts__Object Playermat that triggered this\n ---@param alwaysFaceUp boolean Whether the card should be drawn face-up\n MythosAreaApi.drawEncounterCard = function(mat, alwaysFaceUp)\n getMythosArea().call(\"drawEncounterCard\", {mat = mat, alwaysFaceUp = alwaysFaceUp})\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"core/NavigationOverlayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local NavigationOverlayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getNOHandler()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"NavigationOverlayHandler\")\n end\n\n -- copies the visibility for the Navigation overlay\n ---@param startColor string Color of the player to copy from\n ---@param targetColor string Color of the targeted player\n NavigationOverlayApi.copyVisibility = function(startColor, targetColor)\n getNOHandler().call(\"copyVisibility\", {\n startColor = startColor,\n targetColor = targetColor\n })\n end\n\n -- changes the Navigation Overlay view (\"Full View\" --\u003e \"Play Areas\" --\u003e \"Closed\" etc.)\n ---@param playerColor string Color of the player to update the visibility for\n NavigationOverlayApi.cycleVisibility = function(playerColor)\n getNOHandler().call(\"cycleVisibility\", playerColor)\n end\n\n -- loads the specified camera for a player\n ---@param player tts__Player Player whose camera should be moved\n ---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to\n NavigationOverlayApi.loadCamera = function(player, camera)\n getNOHandler().call(\"loadCameraFromApi\", {\n player = player,\n camera = camera\n })\n end\n\n return NavigationOverlayApi\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/token/TokenChecker\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local CHAOS_TOKEN_NAMES = {\n [\"Elder Sign\"] = true,\n [\"+1\"] = true,\n [\"0\"] = true,\n [\"-1\"] = true,\n [\"-2\"] = true,\n [\"-3\"] = true,\n [\"-4\"] = true,\n [\"-5\"] = true,\n [\"-6\"] = true,\n [\"-7\"] = true,\n [\"-8\"] = true,\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n [\"Auto-fail\"] = true,\n [\"Bless\"] = true,\n [\"Curse\"] = true,\n [\"Frost\"] = true\n }\n\n local TokenChecker = {}\n\n -- returns true if the passed object is a chaos token (by name)\n TokenChecker.isChaosToken = function(obj)\n if obj.type == \"Tile\" and CHAOS_TOKEN_NAMES[obj.getName()] then\n return true\n else\n return false\n end\n end\n\n return TokenChecker\nend\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror\n -- tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned) spawned.setState(tokenValue) end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"playermat/Playmat\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal deckLib = require(\"util/DeckLib\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal navigationOverlayApi = require(\"core/NavigationOverlayApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenChecker = require(\"core/token/TokenChecker\")\nlocal tokenManager = require(\"core/token/TokenManager\")\n\n-- we use this to turn off collision handling until onLoad() is complete\nlocal collisionEnabled = false\n\n-- x-Values for discard buttons\nlocal DISCARD_BUTTON_OFFSETS = {-1.365, -0.91, -0.455, 0, 0.455, 0.91}\n\nlocal SEARCH_AROUND_SELF_X_BUFFER = 8\n\n-- defined areas for object searching\nlocal MAIN_PLAY_AREA = {\n upperLeft = {\n x = 1.98,\n z = 0.736\n },\n lowerRight = {\n x = -0.79,\n z = -0.39\n }\n}\nlocal INVESTIGATOR_AREA = {\n upperLeft = {\n x = -1.084,\n z = 0.06517\n },\n lowerRight = {\n x = -1.258,\n z = -0.0805\n }\n}\nlocal THREAT_AREA = {\n upperLeft = {\n x = 1.53,\n z = -0.34\n },\n lowerRight = {\n x = -1.13,\n z = -0.92\n }\n}\nlocal DECK_DISCARD_AREA = {\n upperLeft = {\n x = -1.62,\n z = 0.855\n },\n lowerRight = {\n x = -2.02,\n z = -0.245\n },\n center = {\n x = -1.82,\n y = 0.5,\n z = 0.305\n },\n size = {\n x = 0.4,\n y = 3,\n z = 1.1\n }\n}\n\n-- local position of draw and discard pile\nlocal DRAW_DECK_POSITION = { x = -1.82, y = 0.1, z = 0 }\nlocal DISCARD_PILE_POSITION = { x = -1.82, y = 0.1, z = 0.61 }\n\n-- global position of encounter discard pile\nlocal ENCOUNTER_DISCARD_POSITION = { x = -3.85, y = 1.5, z = 10.38}\n\n-- global variable so it can be reset by the Clean Up Helper\nactiveInvestigatorId = \"00000\"\n\n-- table of type-object reference pairs of all owned objects\nlocal ownedObjects = {}\nlocal matColor = self.getMemo()\n\n-- variable to track the status of the \"Show Draw Button\" option\nlocal isDrawButtonVisible = false\n\n-- global variable to report \"Dream-Enhancing Serum\" status\nisDES = false\n\nfunction onSave()\n return JSON.encode({\n playerColor = playerColor,\n activeInvestigatorId = activeInvestigatorId,\n isDrawButtonVisible = isDrawButtonVisible\n })\nend\n\nfunction onLoad(saveState)\n self.interactable = false\n\n -- get object references to owned objects\n ownedObjects = guidReferenceApi.getObjectsByOwner(matColor)\n\n -- button creation\n for i = 1, 6 do\n makeDiscardButton(DISCARD_BUTTON_OFFSETS[i], i)\n end\n\n self.createButton({\n click_function = \"drawEncounterCard\",\n function_owner = self,\n position = {-1.84, 0, -0.65},\n rotation = {0, 80, 0},\n width = 265,\n height = 190\n })\n\n self.createButton({\n click_function = \"drawChaosTokenButton\",\n function_owner = self,\n position = {1.85, 0, -0.74},\n rotation = {0, -45, 0},\n width = 135,\n height = 135\n })\n\n self.createButton({\n label = \"Upkeep\",\n click_function = \"doUpkeep\",\n function_owner = self,\n position = {1.84, 0.1, -0.44},\n scale = {0.12, 0.12, 0.12},\n width = 800,\n height = 280,\n font_size = 180\n })\n\n -- save state loading\n local state = JSON.decode(saveState)\n if state ~= nil then\n playerColor = state.playerColor\n activeInvestigatorId = state.activeInvestigatorId\n isDrawButtonVisible = state.isDrawButtonVisible\n end\n\n showDrawButton(isDrawButtonVisible)\n math.randomseed(os.time())\n Wait.time(function() collisionEnabled = true end, 0.1)\nend\n\n---------------------------------------------------------\n-- utility functions\n---------------------------------------------------------\n\n-- searches an area and optionally filters the result\nfunction searchArea(origin, size, filter)\n return searchLib.inArea(origin, self.getRotation(), size, filter)\nend\n\n-- finds all objects on the playmat and associated set aside zone.\nfunction searchAroundSelf(filter)\n local bounds = self.getBoundsNormalized()\n -- Increase the width to cover the set aside zone\n bounds.size.x = bounds.size.x + SEARCH_AROUND_SELF_X_BUFFER\n bounds.size.y = 1\n -- Since the cast is centered on the position, shift left or right to keep the non-set aside edge\n -- of the cast at the edge of the playmat\n -- setAsideDirection accounts for the set aside zone being on the left or right, depending on the\n -- table position of the playmat\n local setAsideDirection = bounds.center.z \u003e 0 and 1 or -1\n local localCenter = self.positionToLocal(bounds.center)\n localCenter.x = localCenter.x + setAsideDirection * SEARCH_AROUND_SELF_X_BUFFER / 2 / self.getScale().x\n return searchArea(self.positionToWorld(localCenter), bounds.size, filter)\nend\n\n-- searches the area around the draw deck and discard pile\nfunction searchDeckAndDiscardArea(filter)\n local pos = self.positionToWorld(DECK_DISCARD_AREA.center)\n local scale = self.getScale()\n local size = {\n x = DECK_DISCARD_AREA.size.x * scale.x,\n y = DECK_DISCARD_AREA.size.y, \n z = DECK_DISCARD_AREA.size.z * scale.z\n }\n return searchArea(pos, size, filter)\nend\n\nfunction doNotReady(card)\n return card.getVar(\"do_not_ready\") or false\nend\n\n-- rounds a number to the specified amount of decimal places\n---@param num number Initial value\n---@param numDecimalPlaces number Amount of decimal places\nfunction round(num, numDecimalPlaces)\n local mult = 10^(numDecimalPlaces or 0)\n return math.floor(num * mult + 0.5) / mult\nend\n\n---------------------------------------------------------\n-- Discard buttons\n---------------------------------------------------------\n\n-- handles discarding for a list of objects\n---@param objList table List of objects to discard\nfunction discardListOfObjects(objList)\n for _, obj in ipairs(objList) do\n if obj.type == \"Card\" or obj.type == \"Deck\" then\n if obj.hasTag(\"PlayerCard\") then\n deckLib.placeOrMergeIntoDeck(obj, returnGlobalDiscardPosition(), self.getRotation())\n else\n deckLib.placeOrMergeIntoDeck(obj, ENCOUNTER_DISCARD_POSITION, {x = 0, y = -90, z = 0})\n end\n -- put chaos tokens back into bag (e.g. Unrelenting)\n elseif tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n -- don't touch locked objects (like the table etc.)\n elseif not obj.getLock() then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n-- build a discard button to discard from searchPosition (number must be unique)\nfunction makeDiscardButton(xValue, number)\n local position = { xValue, 0.1, -0.94}\n local searchPosition = {-position[1], position[2], position[3] + 0.32}\n local handlerName = 'handler' .. number\n self.setVar(handlerName, function()\n local cardSizeSearch = {2, 1, 3.2}\n local globalSearchPosition = self.positionToWorld(searchPosition)\n local searchResult = searchArea(globalSearchPosition, cardSizeSearch)\n return discardListOfObjects(searchResult)\n end)\n self.createButton({\n label = \"Discard\",\n click_function = handlerName,\n function_owner = self,\n position = position,\n scale = {0.12, 0.12, 0.12},\n width = 900,\n height = 350,\n font_size = 220\n })\nend\n\n---------------------------------------------------------\n-- Upkeep button\n---------------------------------------------------------\n\n-- calls the Upkeep function with correct parameter\nfunction doUpkeepFromHotkey(color)\n doUpkeep(_, color)\nend\n\nfunction doUpkeep(_, clickedByColor, isRightClick)\n if isRightClick then\n changeColor(clickedByColor)\n return\n end\n\n -- send messages to player who clicked button if no seated player found\n messageColor = Player[playerColor].seated and playerColor or clickedByColor\n\n -- unexhaust cards in play zone, flip action tokens and find forcedLearning\n local forcedLearning = false\n local rot = self.getRotation()\n for _, obj in ipairs(searchAroundSelf()) do\n if obj.getDescription() == \"Action Token\" and obj.is_face_down then\n obj.flip()\n elseif obj.type == \"Card\" and not inArea(self.positionToLocal(obj.getPosition()), INVESTIGATOR_AREA) then\n local cardMetadata = JSON.decode(obj.getGMNotes()) or {}\n if not doNotReady(obj) then\n local cardRotation = round(obj.getRotation().y, 0) - rot.y\n local yRotDiff = 0\n\n if cardRotation \u003c 0 then\n cardRotation = cardRotation + 360\n end\n\n -- rotate cards to the next multiple of 90° towards 0°\n if cardRotation \u003e 90 and cardRotation \u003c= 180 then\n yRotDiff = 90\n elseif cardRotation \u003c 270 and cardRotation \u003e 180 then\n yRotDiff = 270\n end\n\n -- set correct rotation for face-down cards\n rot.z = obj.is_face_down and 180 or 0\n obj.setRotation({rot.x, rot.y + yRotDiff, rot.z})\n end\n if cardMetadata.id == \"08031\" then\n forcedLearning = true\n end\n if cardMetadata.uses ~= nil then\n tokenManager.maybeReplenishCard(obj, cardMetadata.uses, self)\n end\n end\n end\n\n -- flip investigator mini-card and summoned servitor mini-card\n -- (all characters allowed to account for custom IDs - e.g. 'Z0000' for TTS Zoop generated IDs)\n local miniId = string.match(activeInvestigatorId, \".....\") .. \"-m\"\n for _, obj in ipairs(getObjects()) do\n if obj.type == \"Card\" and obj.is_face_down then\n local notes = JSON.decode(obj.getGMNotes())\n if notes ~= nil and notes.type == \"Minicard\" and (notes.id == miniId or notes.id == \"09080-m\") then\n obj.flip()\n end\n end\n end\n\n -- gain a resource (or two if playing Jenny Barnes)\n if string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"02003\" then\n updateCounter({type = \"ResourceCounter\", modifier = 2})\n printToColor(\"Gaining 2 resources (Jenny)\", messageColor)\n else\n updateCounter({type = \"ResourceCounter\", modifier = 1})\n end\n\n -- draw a card (with handling for Patrice and Forced Learning)\n if activeInvestigatorId == \"06005\" then\n if forcedLearning then\n printToColor(\"Wow, did you really take 'Versatile' to play Patrice with 'Forced Learning'? Choose which draw replacement effect takes priority and draw cards accordingly.\", messageColor)\n else\n local handSize = #Player[playerColor].getHandObjects()\n if handSize \u003c 5 then\n local cardsToDraw = 5 - handSize\n printToColor(\"Drawing \" .. cardsToDraw .. \" cards (Patrice)\", messageColor)\n drawCardsWithReshuffle(cardsToDraw)\n end\n end\n elseif forcedLearning then\n printToColor(\"Drawing 2 cards, discard 1 (Forced Learning)\", messageColor)\n drawCardsWithReshuffle(2)\n elseif activeInvestigatorId == \"89001\" then\n printToColor(\"Drawing 2 cards (Subject 5U-21)\", messageColor)\n drawCardsWithReshuffle(2)\n else\n drawCardsWithReshuffle(1)\n end\nend\n\n-- function for \"draw 1 button\" (that can be added via option panel)\nfunction doDrawOne(_, color)\n -- send messages to player who clicked button if no seated player found\n messageColor = Player[playerColor].seated and playerColor or color\n drawCardsWithReshuffle(1)\nend\n\n-- draw X cards (shuffle discards if necessary)\nfunction drawCardsWithReshuffle(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n\n -- Norman Withers handling\n local harbinger = false\n if deckAreaObjects.topCard and deckAreaObjects.topCard.getName() == \"The Harbinger\" then\n harbinger = true\n elseif deckAreaObjects.draw and not deckAreaObjects.draw.is_face_down then\n local cards = deckAreaObjects.draw.getObjects()\n if cards[#cards].name == \"The Harbinger\" then\n harbinger = true\n end\n end\n\n if harbinger then\n printToColor(\"The Harbinger is on top of your deck, not drawing cards\", messageColor)\n return\n end\n\n local topCardDetected = false\n if deckAreaObjects.topCard ~= nil then\n deckAreaObjects.topCard.deal(1, playerColor)\n topCardDetected = true\n numCards = numCards - 1\n if numCards == 0 then\n flipTopCardFromDeck()\n return\n end\n end\n\n local deckSize = 1\n if deckAreaObjects.draw == nil then\n deckSize = 0\n elseif deckAreaObjects.draw.type == \"Deck\" then\n deckSize = #deckAreaObjects.draw.getObjects()\n end\n\n if deckSize \u003e= numCards then\n drawCards(numCards)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n else\n drawCards(deckSize)\n if deckAreaObjects.discard ~= nil then\n shuffleDiscardIntoDeck()\n Wait.time(function()\n drawCards(numCards - deckSize)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n end, 1)\n end\n printToColor(\"Take 1 horror (drawing card from empty deck)\", messageColor)\n end\nend\n\n-- get the draw deck and discard pile objects and returns the references\nfunction getDeckAreaObjects()\n local deckAreaObjects = {}\n for _, object in ipairs(searchDeckAndDiscardArea(\"isCardOrDeck\")) do\n if self.positionToLocal(object.getPosition()).z \u003e 0.5 then\n deckAreaObjects.discard = object\n -- Norman Withers handling\n elseif object.type == \"Card\" and not object.is_face_down then\n deckAreaObjects.topCard = object\n else\n deckAreaObjects.draw = object\n end\n end\n return deckAreaObjects\nend\n\nfunction drawCards(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.draw then\n deckAreaObjects.draw.deal(numCards, playerColor)\n end\nend\n\nfunction shuffleDiscardIntoDeck()\n local deckAreaObjects = getDeckAreaObjects()\n if not deckAreaObjects.discard.is_face_down then\n deckAreaObjects.discard.flip()\n end\n deckAreaObjects.discard.shuffle()\n deckAreaObjects.discard.setPositionSmooth(self.positionToWorld(DRAW_DECK_POSITION), false, false)\nend\n\n-- utility function for Norman Withers to flip the top card to the revealed side\nfunction flipTopCardFromDeck()\n Wait.time(function()\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.topCard then\n elseif deckAreaObjects.draw then\n if deckAreaObjects.draw.type == \"Card\" then\n deckAreaObjects.draw.flip()\n else\n -- get bounds to know the height of the deck\n local bounds = deckAreaObjects.draw.getBounds()\n local pos = bounds.center + Vector(0, bounds.size.y / 2 + 0.2, 0)\n deckAreaObjects.draw.takeObject({ position = pos, flip = true })\n end\n end\n end, 0.1)\nend\n\n-- discard a random non-hidden card from hand\nfunction doDiscardOne()\n local hand = Player[playerColor].getHandObjects()\n if #hand == 0 then\n broadcastToAll(\"Cannot discard from empty hand!\", \"Red\")\n else\n local choices = {}\n for i = 1, #hand do\n local notes = JSON.decode(hand[i].getGMNotes())\n if notes ~= nil then\n if notes.hidden ~= true then\n table.insert(choices, i)\n end\n else\n table.insert(choices, i)\n end\n end\n\n if #choices == 0 then\n broadcastToAll(\"Hidden cards can't be randomly discarded.\", \"Orange\")\n return\n end\n\n -- get a random non-hidden card (from the \"choices\" table)\n local num = math.random(1, #choices)\n deckLib.placeOrMergeIntoDeck(hand[choices[num]], returnGlobalDiscardPosition(), self.getRotation())\n\n local playerName = Player[playerColor].steam_name or playerColor\n broadcastToAll(playerName .. \" randomly discarded card \" .. choices[num] .. \"/\" .. #hand .. \".\", \"White\")\n end\nend\n\n---------------------------------------------------------\n-- color related functions\n---------------------------------------------------------\n\n-- changes the player color\nfunction changeColor(clickedByColor)\n local colorList = {\n \"White\",\n \"Brown\",\n \"Red\",\n \"Orange\",\n \"Yellow\",\n \"Green\",\n \"Teal\",\n \"Blue\",\n \"Purple\",\n \"Pink\"\n }\n\n -- remove existing colors from the list of choices\n for _, existingColor in ipairs(Player.getAvailableColors()) do\n for i, newColor in ipairs(colorList) do\n if existingColor == newColor then\n table.remove(colorList, i)\n end\n end\n end\n\n -- show the option dialog for color selection to the player that triggered this\n Player[clickedByColor].showOptionsDialog(\"Select a new color:\", colorList, _, function(color)\n -- update the color of the hand zone\n local handZone = ownedObjects.HandZone\n handZone.setValue(color)\n\n -- if the seated player clicked this, reseat him to the new color\n if clickedByColor == playerColor then\n navigationOverlayApi.copyVisibility(playerColor, color)\n Player[playerColor].changeColor(color)\n end\n\n -- update the internal variable\n playerColor = color\n end)\nend\n\n---------------------------------------------------------\n-- playmat token spawning\n---------------------------------------------------------\n\n-- Finds all customizable cards in this play area and updates their metadata based on the selections\n-- on the matching upgrade sheet.\n-- This method is theoretically O(n^2), and should be used sparingly. In practice it will only be\n-- called when a checkbox is added or removed in-game (which should be rare), and is bounded by the\n-- number of customizable cards in play.\nfunction syncAllCustomizableCards()\n for _, card in ipairs(searchAroundSelf(\"isCard\")) do\n syncCustomizableMetadata(card)\n end\nend\n\nfunction syncCustomizableMetadata(card)\n local cardMetadata = JSON.decode(card.getGMNotes()) or { }\n if cardMetadata == nil or cardMetadata.customizations == nil then\n return\n end\n for _, upgradeSheet in ipairs(searchAroundSelf(\"isCard\")) do\n local upgradeSheetMetadata = JSON.decode(upgradeSheet.getGMNotes()) or { }\n if upgradeSheetMetadata.id == (cardMetadata.id .. \"-c\") then\n for i, customization in ipairs(cardMetadata.customizations) do\n if customization.replaces ~= nil and customization.replaces.uses ~= nil then\n -- Allowed use of call(), no APIs for individual cards\n if upgradeSheet.call(\"isUpgradeActive\", i) then\n cardMetadata.uses = customization.replaces.uses\n card.setGMNotes(JSON.encode(cardMetadata))\n else\n -- TODO: Get the original metadata to restore it... maybe. This should only be\n -- necessary in the very unlikely case that a user un-checks a previously-full upgrade\n -- row while the card is in play. It will be much easier once the AllPlayerCardsApi is\n -- in place, so defer until it is\n end\n end\n end\n end\n end\nend\n\nfunction spawnTokensFor(object)\n local extraUses = { }\n if activeInvestigatorId == \"03004\" then\n extraUses[\"Charge\"] = 1\n end\n\n tokenManager.spawnForCard(object, extraUses)\nend\n\nfunction onCollisionEnter(collisionInfo)\n local object = collisionInfo.collision_object\n\n -- only continue if loading is completed\n if not collisionEnabled then return end\n\n -- only continue for cards\n if object.type ~= \"Card\" then return end\n\n -- detect if \"Dream-Enhancing Serum\" is placed\n if object.getName() == \"Dream-Enhancing Serum\" then isDES = true end\n\n maybeUpdateActiveInvestigator(object)\n syncCustomizableMetadata(object)\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n elseif shouldSpawnTokens(object) then\n spawnTokensFor(object)\n end\nend\n\n-- detect if \"Dream-Enhancing Serum\" is removed\nfunction onCollisionExit(collisionInfo)\n if collisionInfo.collision_object.getName() == \"Dream-Enhancing Serum\" then isDES = false end\nend\n\n-- checks if tokens should be spawned for the provided card\nfunction shouldSpawnTokens(card)\n if card.is_face_down then\n return false\n end\n\n local localCardPos = self.positionToLocal(card.getPosition())\n local metadata = JSON.decode(card.getGMNotes())\n\n -- If no metadata we don't know the type, so only spawn in the main area\n if metadata == nil then\n return inArea(localCardPos, MAIN_PLAY_AREA)\n end\n\n -- Spawn tokens for assets and events on the main area\n if inArea(localCardPos, MAIN_PLAY_AREA)\n and (metadata.type == \"Asset\"\n or metadata.type == \"Event\") then\n return true\n end\n\n -- Spawn tokens for all encounter types in the threat area\n if inArea(localCardPos, THREAT_AREA)\n and (metadata.type == \"Treachery\"\n or metadata.type == \"Enemy\"\n or metadata.weakness) then\n return true\n end\n\n return false\nend\n\nfunction onObjectEnterContainer(container, object)\n if object.type ~= \"Card\" then return end\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n end\nend\n\n-- removes tokens from the provided card/deck\nfunction removeTokensFromObject(object)\n if object.hasTag(\"CardThatSeals\") then\n local func = object.getVar(\"resetSealedTokens\") -- check if function exists (it won't for older custom content)\n if func ~= nil then\n object.call(\"resetSealedTokens\")\n end\n end\n\n for _, obj in ipairs(searchLib.onObject(object)) do\n if tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n elseif obj.getGUID() ~= \"4ee1f2\" and -- table\n obj ~= self and\n obj.type ~= \"Deck\" and\n obj.type ~= \"Card\" and\n obj.memo ~= nil and\n obj.getLock() == false and\n obj.getDescription() ~= \"Action Token\" then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n---------------------------------------------------------\n-- investigator ID grabbing and skill tracker\n---------------------------------------------------------\n\nfunction maybeUpdateActiveInvestigator(card)\n if not inArea(self.positionToLocal(card.getPosition()), INVESTIGATOR_AREA) then return end\n\n local notes = JSON.decode(card.getGMNotes())\n local class\n\n if notes ~= nil and notes.type == \"Investigator\" and notes.id ~= nil then\n if notes.id == activeInvestigatorId then return end\n class = notes.class\n activeInvestigatorId = notes.id\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", {\n notes.willpowerIcons,\n notes.intellectIcons,\n notes.combatIcons,\n notes.agilityIcons\n })\n elseif activeInvestigatorId ~= \"00000\" then\n class = \"Neutral\"\n activeInvestigatorId = \"00000\"\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", {1, 1, 1, 1})\n else\n return\n end\n\n -- change state of action tokens\n local search = searchArea(self.positionToWorld({-1.1, 0.05, -0.27}), {4, 1, 1})\n local smallToken = nil\n local STATE_TABLE = {\n [\"Guardian\"] = 1,\n [\"Seeker\"] = 2,\n [\"Rogue\"] = 3,\n [\"Mystic\"] = 4,\n [\"Survivor\"] = 5,\n [\"Neutral\"] = 6\n }\n\n for _, obj in ipairs(search) do\n if obj.getDescription() == \"Action Token\" and obj.getStateId() \u003e 0 then\n if obj.getScale().x \u003c 0.4 then\n smallToken = obj\n else\n setObjectState(obj, STATE_TABLE[class])\n end\n end\n end\n\n -- update the small token with special action for certain investigators\n local SPECIAL_ACTIONS = {\n [\"04002\"] = 8, -- Ursula Downs\n [\"01002\"] = 9, -- Daisy Walker\n [\"01502\"] = 9, -- Daisy Walker\n [\"01002-pb\"] = 9, -- Daisy Walker\n [\"06003\"] = 10, -- Tony Morgan\n [\"04003\"] = 11, -- Finn Edwards\n [\"08016\"] = 14 -- Bob Jenkins\n }\n\n if smallToken ~= nil then\n setObjectState(smallToken, SPECIAL_ACTIONS[activeInvestigatorId] or STATE_TABLE[class])\n end\nend\n\nfunction setObjectState(obj, stateId)\n if obj.getStateId() ~= stateId then obj.setState(stateId) end\nend\n\n---------------------------------------------------------\n-- manipulation of owned objects\n---------------------------------------------------------\n\n-- updates the specific owned counter\n---@param param table Contains the information to update:\n--- type: String Counter to target\n--- newValue: Number Value to set the counter to\n--- modifier: Number If newValue is not provided, the existing value will be adjusted by this modifier\nfunction updateCounter(param)\n local counter = ownedObjects[param.type]\n if counter ~= nil then\n counter.call(\"updateVal\", param.newValue or (counter.getVar(\"val\") + param.modifier))\n else\n printToAll(param.type .. \" for \" .. matColor .. \" could not be found.\", \"Yellow\")\n end\nend\n\n-- returns the resource counter amount\n---@param type string Counter to target\nfunction getCounterValue(type)\n return ownedObjects[type].getVar(\"val\")\nend\n\n-- set investigator skill tracker to \"1, 1, 1, 1\"\nfunction resetSkillTracker()\n local obj = ownedObjects.InvestigatorSkillTracker\n if obj ~= nil then\n obj.call(\"updateStats\", { 1, 1, 1, 1 })\n else\n printToAll(\"Skill tracker for \" .. matColor .. \" playmat could not be found.\", \"Yellow\")\n end\nend\n\n---------------------------------------------------------\n-- calls to 'Global' / functions for calls from outside\n---------------------------------------------------------\n\nfunction drawChaosTokenButton(_, _, isRightClick)\n chaosBagApi.drawChaosToken(self, isRightClick)\nend\n\nfunction drawEncounterCard(_, _, isRightClick)\n mythosAreaApi.drawEncounterCard(self, isRightClick)\nend\n\nfunction returnGlobalDiscardPosition()\n return self.positionToWorld(DISCARD_PILE_POSITION)\nend\n\n-- Sets this playermat's draw 1 button to visible\n---@param visible boolean Whether the draw 1 button should be visible\nfunction showDrawButton(visible)\n isDrawButtonVisible = visible\n\n -- create the \"Draw 1\" button\n if isDrawButtonVisible then\n self.createButton({\n label = \"Draw 1\",\n click_function = \"doDrawOne\",\n function_owner = self,\n position = { 1.84, 0.1, -0.36 },\n scale = { 0.12, 0.12, 0.12 },\n width = 800,\n height = 280,\n font_size = 180\n })\n\n -- remove the \"Draw 1\" button\n else\n local buttons = self.getButtons()\n for i = 1, #buttons do\n if buttons[i].label == \"Draw 1\" then\n self.removeButton(buttons[i].index)\n end\n end\n end\nend\n\n-- shows / hides a clickable clue counter for this playmat and sets the correct amount of clues\n---@param showCounter boolean Whether the clickable clue counter should be visible\nfunction clickableClues(showCounter)\n local clickerPos = ownedObjects.ClickableClueCounter.getPosition()\n local clueCount = 0\n \n -- move clue counters\n local modY = showCounter and 0.525 or -0.525\n ownedObjects.ClickableClueCounter.setPosition(clickerPos + Vector(0, modY, 0))\n\n if showCounter then\n -- current clue count\n clueCount = ownedObjects.ClueCounter.getVar(\"exposedValue\")\n\n -- remove clues\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n\n -- set value for clue clickers\n ownedObjects.ClickableClueCounter.call(\"updateVal\", clueCount)\n else\n -- current clue count\n clueCount = ownedObjects.ClickableClueCounter.getVar(\"val\")\n\n -- spawn clues\n local pos = self.positionToWorld({x = -1.12, y = 0.05, z = 0.7})\n for i = 1, clueCount do\n pos.y = pos.y + 0.045 * i\n tokenManager.spawnToken(pos, \"clue\", self.getRotation())\n end\n end\nend\n\n-- removes all clues (moving tokens to the trash and setting counters to 0)\nfunction removeClues()\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n ownedObjects.ClickableClueCounter.call(\"updateVal\", 0)\nend\n\n-- reports the clue count\n---@param useClickableCounters boolean Controls which type of counter is getting checked\nfunction getClueCount(useClickableCounters)\n if useClickableCounters then\n return ownedObjects.ClickableClueCounter.getVar(\"val\")\n else\n return ownedObjects.ClueCounter.getVar(\"exposedValue\")\n end\nend\n\n-- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes\n-- is true, the main card slot snap points will only snap assets, while the investigator area point\n-- will only snap Investigators. If matchTypes is false, snap points will be reset to snap all cards.\n---@param matchTypes boolean Whether snap points should only snap for the matching card types.\nfunction setLimitSnapsByType(matchTypes)\n local snaps = self.getSnapPoints()\n for i, snap in ipairs(snaps) do\n local snapPos = snap.position\n if inArea(snapPos, MAIN_PLAY_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Asset\" }\n else\n table.insert(snaps[i].tags, \"Asset\")\n end\n else\n snaps[i].tags = nil\n end\n end\n if inArea(snapPos, INVESTIGATOR_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Investigator\" }\n else\n table.insert(snaps[i].tags, \"Investigator\")\n end\n else\n snaps[i].tags = nil\n end\n end\n end\n self.setSnapPoints(snaps)\nend\n\n-- Simple method to check if the given point is in a specified area. Local use only,\n---@param point tts__Vector Point to check, only x and z values are relevant\n---@param bounds table Defined area to see if the point is within. See MAIN_PLAY_AREA for sample\n-- bounds definition.\n---@return boolean: True if the point is in the area defined by bounds\nfunction inArea(point, bounds)\n return (point.x \u003c bounds.upperLeft.x\n and point.x \u003e bounds.lowerRight.x\n and point.z \u003c bounds.upperLeft.z\n and point.z \u003e bounds.lowerRight.z)\nend\n\n-- called by custom data helpers to add player card data\n---@param args table Contains only one entry, the GUID of the custom data helper\nfunction updatePlayerCards(args)\n local customDataHelper = getObjectFromGUID(args[1])\n local playerCardData = customDataHelper.getTable(\"PLAYER_CARD_DATA\")\n tokenManager.addPlayerCardData(playerCardData)\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot table New rotation for the object (optional)\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local newPos\n local offset = 0.5\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n else\n newPos = Vector(pos) + Vector(0, offset, 0)\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", - "LuaScriptState": "{\"activeInvestigatorId\":\"00000\",\"isDrawButtonVisible\":false,\"playerColor\":\"White\"}", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat to the first empty spot from the right \n ---@param matColor string Playermat that triggered this\n ---@param position tts__Vector Position for the encounter card\n MythosAreaApi.drawEncounterCard = function(matColor, position)\n getMythosArea().call(\"drawEncounterCard\", { matColor = matColor, position = position })\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"core/NavigationOverlayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local NavigationOverlayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getNOHandler()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"NavigationOverlayHandler\")\n end\n\n -- copies the visibility for the Navigation overlay\n ---@param startColor string Color of the player to copy from\n ---@param targetColor string Color of the targeted player\n NavigationOverlayApi.copyVisibility = function(startColor, targetColor)\n getNOHandler().call(\"copyVisibility\", {\n startColor = startColor,\n targetColor = targetColor\n })\n end\n\n -- changes the Navigation Overlay view (\"Full View\" --\u003e \"Play Areas\" --\u003e \"Closed\" etc.)\n ---@param playerColor string Color of the player to update the visibility for\n NavigationOverlayApi.cycleVisibility = function(playerColor)\n getNOHandler().call(\"cycleVisibility\", playerColor)\n end\n\n -- loads the specified camera for a player\n ---@param player tts__Player Player whose camera should be moved\n ---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to\n NavigationOverlayApi.loadCamera = function(player, camera)\n getNOHandler().call(\"loadCameraFromApi\", {\n player = player,\n camera = camera\n })\n end\n\n return NavigationOverlayApi\nend\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned)\n -- token starts in state 1, so don't attempt to change it to avoid error\n if tokenValue ~= 1 then\n spawned.setState(tokenValue)\n end\n end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot? table New rotation for the object\n ---@param below? boolean Should the object be placed below an existing deck?\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot, below)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local offset = 0.5\n local newPos = Vector(pos) + Vector(0, offset, 0)\n\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n if below then\n newPos = Vector(pos):setAt(\"y\", bounds.center.y - bounds.size.y / 2)\n else\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n end\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/Playmat\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal deckLib = require(\"util/DeckLib\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal navigationOverlayApi = require(\"core/NavigationOverlayApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenChecker = require(\"core/token/TokenChecker\")\nlocal tokenManager = require(\"core/token/TokenManager\")\n\n-- we use this to turn off collision handling until onLoad() is complete\nlocal collisionEnabled = false\nlocal currentlyEditingSlots = false\n\n-- x-Values for discard buttons\nlocal DISCARD_BUTTON_X_START = -1.365\nlocal DISCARD_BUTTON_X_OFFSET = 0.455\n\nlocal SEARCH_AROUND_SELF_X_BUFFER = 8\n\n-- defined areas for object searching\nlocal MAIN_PLAY_AREA = {\n upperLeft = { x = 1.98, z = 0.736 },\n lowerRight = { x = -0.79, z = -0.39 }\n}\nlocal INVESTIGATOR_AREA = {\n upperLeft = { x = -1.084, z = 0.06517 },\n lowerRight = { x = -1.258, z = -0.0805 }\n}\nlocal THREAT_AREA = {\n upperLeft = { x = 1.53, z = -0.34 },\n lowerRight = { x = -1.13, z = -0.92 }\n}\nlocal DECK_DISCARD_AREA = {\n upperLeft = { x = -1.62, z = 0.855 },\n lowerRight = { x = -2.02, z = -0.245 },\n center = { x = -1.82, y = 0.5, z = 0.305 },\n size = { x = 0.4, y = 3, z = 1.1 }\n}\n\n-- local positions\nlocal DRAW_DECK_POSITION = { x = -1.82, y = 0.1, z = 0 }\nlocal DISCARD_PILE_POSITION = { x = -1.82, y = 0.1, z = 0.61 }\nlocal DRAWN_ENCOUNTER_POSITION = { x = 1.365, y = 0.5, z = -0.625 }\n\n-- global position of encounter discard pile\nlocal ENCOUNTER_DISCARD_POSITION = { x = -3.85, y = 1.5, z = 10.38 }\n\n-- used for the buttons on the right side of the playmat\n-- starts off with the data for the \"Upkeep\" button and will then be changed\nlocal buttonParameters = {\n label = \"Upkeep\",\n click_function = \"doUpkeep\",\n tooltip = \"Right-click to change color\",\n function_owner = self,\n position = { x = 1.82, y = 0.1, z = -0.45 },\n scale = { 0.12, 0.12, 0.12 },\n width = 1000,\n height = 280,\n font_size = 180\n}\n\n-- translation table for slot names to characters for special font\nlocal slotNameToChar = {\n [\"any\"] = \"\",\n [\"Accessory\"] = \"C\",\n [\"Ally\"] = \"E\",\n [\"Arcane\"] = \"G\",\n [\"Body\"] = \"K\",\n [\"Hand (right)\"] = \"M\",\n [\"Hand (left)\"] = \"M\",\n [\"Hand x2\"] = \"N\",\n [\"Tarot\"] = \"A\"\n}\n\n-- slot symbol for the respective slot (from top left to bottom right)\nlocal slotData = {}\nlocal defaultSlotData = {\n -- 1st row\n \"any\", \"any\", \"any\", \"Tarot\", \"Hand (left)\", \"Hand (right)\", \"Ally\",\n\n -- 2nd row\n \"any\", \"any\", \"any\", \"Accessory\", \"Arcane\", \"Arcane\", \"Body\"\n}\n\n-- global variable so it can be reset by the Clean Up Helper\nactiveInvestigatorId = \"00000\"\nlocal isDrawButtonVisible = false\n\n-- global variable to report \"Dream-Enhancing Serum\" status\nisDES = false\n\n-- table of type-object reference pairs of all owned objects\nlocal ownedObjects = {}\nlocal matColor = self.getMemo()\n\nfunction onSave()\n return JSON.encode({\n playerColor = playerColor,\n activeInvestigatorId = activeInvestigatorId,\n isDrawButtonVisible = isDrawButtonVisible,\n slotData = slotData\n })\nend\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n playerColor = loadedData.playerColor\n activeInvestigatorId = loadedData.activeInvestigatorId\n isDrawButtonVisible = loadedData.isDrawButtonVisible\n slotData = loadedData.slotData\n end\n\n self.interactable = false\n\n -- get object references to owned objects\n ownedObjects = guidReferenceApi.getObjectsByOwner(matColor)\n\n -- discard button creation\n for i = 1, 6 do\n makeDiscardButton(i)\n end\n\n self.createButton({\n click_function = \"drawEncounterCard\",\n function_owner = self,\n position = { -1.84, 0, -0.65 },\n rotation = { 0, 80, 0 },\n width = 265,\n height = 190\n })\n\n self.createButton({\n click_function = \"drawChaosTokenButton\",\n function_owner = self,\n position = { 1.85, 0, -0.74 },\n rotation = { 0, -45, 0 },\n width = 135,\n height = 135\n })\n\n -- Upkeep button: can use the default parameters for this\n self.createButton(buttonParameters)\n\n -- Slot editing button: modified default data\n buttonParameters.label = \"Edit Slots\"\n buttonParameters.click_function = \"toggleSlotEditing\"\n buttonParameters.tooltip = \"Right-click to reset slot symbols\"\n buttonParameters.position.z = 0.92\n self.createButton(buttonParameters)\n\n showDrawButton(isDrawButtonVisible)\n redrawSlotSymbols()\n math.randomseed(os.time())\n Wait.time(function() collisionEnabled = true end, 0.1)\nend\n\n---------------------------------------------------------\n-- utility functions\n---------------------------------------------------------\n\n-- searches an area and optionally filters the result\nfunction searchArea(origin, size, filter)\n return searchLib.inArea(origin, self.getRotation(), size, filter)\nend\n\n-- finds all objects on the playmat and associated set aside zone.\nfunction searchAroundSelf(filter)\n local bounds = self.getBoundsNormalized()\n -- Increase the width to cover the set aside zone\n bounds.size.x = bounds.size.x + SEARCH_AROUND_SELF_X_BUFFER\n bounds.size.y = 1\n -- Since the cast is centered on the position, shift left or right to keep the non-set aside edge\n -- of the cast at the edge of the playmat\n -- setAsideDirection accounts for the set aside zone being on the left or right, depending on the\n -- table position of the playmat\n local setAsideDirection = bounds.center.z \u003e 0 and 1 or -1\n local localCenter = self.positionToLocal(bounds.center)\n localCenter.x = localCenter.x + setAsideDirection * SEARCH_AROUND_SELF_X_BUFFER / 2 / self.getScale().x\n return searchArea(self.positionToWorld(localCenter), bounds.size, filter)\nend\n\n-- searches the area around the draw deck and discard pile\nfunction searchDeckAndDiscardArea(filter)\n local pos = self.positionToWorld(DECK_DISCARD_AREA.center)\n local scale = self.getScale()\n local size = {\n x = DECK_DISCARD_AREA.size.x * scale.x,\n y = DECK_DISCARD_AREA.size.y,\n z = DECK_DISCARD_AREA.size.z * scale.z\n }\n return searchArea(pos, size, filter)\nend\n\n-- rounds a number to the specified amount of decimal places\n---@param num number Initial value\n---@param numDecimalPlaces number Amount of decimal places\n---@return number: rounded number\nfunction round(num, numDecimalPlaces)\n local mult = 10 ^ (numDecimalPlaces or 0)\n return math.floor(num * mult + 0.5) / mult\nend\n\n-- edits the label of a button\n---@param oldLabel string Old label of the button\n---@param newLabel string New label of the button\nfunction editButtonLabel(oldLabel, newLabel)\n local buttons = self.getButtons()\n for i = 1, #buttons do\n if buttons[i].label == oldLabel then\n self.editButton({ index = buttons[i].index, label = newLabel })\n end\n end\nend\n\n-- updates the internal \"messageColor\" which is used for print/broadcast statements if no player is seated\n---@param clickedByColor string Colorstring of player who clicked a button\nfunction updateMessageColor(clickedByColor)\n messageColor = Player[playerColor].seated and playerColor or clickedByColor\nend\n\n---------------------------------------------------------\n-- Discard buttons\n---------------------------------------------------------\n\n-- handles discarding for a list of objects\n---@param objList table List of objects to discard\nfunction discardListOfObjects(objList)\n for _, obj in ipairs(objList) do\n if obj.type == \"Card\" or obj.type == \"Deck\" then\n if obj.hasTag(\"PlayerCard\") then\n deckLib.placeOrMergeIntoDeck(obj, returnGlobalDiscardPosition(), self.getRotation())\n else\n deckLib.placeOrMergeIntoDeck(obj, ENCOUNTER_DISCARD_POSITION, { x = 0, y = -90, z = 0 })\n end\n\n -- put chaos tokens back into bag (e.g. Unrelenting)\n elseif tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n\n -- don't touch locked objects (like the table etc.) or specific objects (like key tokens)\n elseif not obj.getLock() and not obj.hasTag(\"DontDiscard\") then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n-- build a discard button to discard from searchPosition\n---@param id number Index of the discard button (from left to right, must be unique)\nfunction makeDiscardButton(id)\n local xValue = DISCARD_BUTTON_X_START + (id - 1) * DISCARD_BUTTON_X_OFFSET\n local position = { xValue, 0.1, -0.94 }\n local searchPosition = { -position[1], position[2], position[3] + 0.32 }\n local handlerName = 'handler' .. id\n self.setVar(handlerName, function()\n local cardSizeSearch = { 2, 1, 3.2 }\n local globalSearchPosition = self.positionToWorld(searchPosition)\n local searchResult = searchArea(globalSearchPosition, cardSizeSearch)\n return discardListOfObjects(searchResult)\n end)\n self.createButton({\n label = \"Discard\",\n click_function = handlerName,\n function_owner = self,\n position = position,\n scale = { 0.12, 0.12, 0.12 },\n width = 900,\n height = 350,\n font_size = 220\n })\nend\n\n---------------------------------------------------------\n-- Upkeep button\n---------------------------------------------------------\n\n-- calls the Upkeep function with correct parameter\nfunction doUpkeepFromHotkey(clickedByColor)\n doUpkeep(_, clickedByColor)\nend\n\nfunction doUpkeep(_, clickedByColor, isRightClick)\n if isRightClick then\n changeColor(clickedByColor)\n return\n end\n\n updateMessageColor(clickedByColor)\n\n -- unexhaust cards in play zone, flip action tokens and find forcedLearning\n local forcedLearning = false\n local rot = self.getRotation()\n for _, obj in ipairs(searchAroundSelf()) do\n if obj.getDescription() == \"Action Token\" and obj.is_face_down then\n obj.flip()\n elseif obj.type == \"Card\" and not inArea(self.positionToLocal(obj.getPosition()), INVESTIGATOR_AREA) then\n local cardMetadata = JSON.decode(obj.getGMNotes()) or {}\n if not (obj.getVar(\"do_not_ready\") or false) then\n local cardRotation = round(obj.getRotation().y, 0) - rot.y\n local yRotDiff = 0\n\n if cardRotation \u003c 0 then\n cardRotation = cardRotation + 360\n end\n\n -- rotate cards to the next multiple of 90° towards 0°\n if cardRotation \u003e 90 and cardRotation \u003c= 180 then\n yRotDiff = 90\n elseif cardRotation \u003c 270 and cardRotation \u003e 180 then\n yRotDiff = 270\n end\n\n -- set correct rotation for face-down cards\n rot.z = obj.is_face_down and 180 or 0\n obj.setRotation({ rot.x, rot.y + yRotDiff, rot.z })\n end\n\n -- detect forced learning to handle card drawing accordingly\n if cardMetadata.id == \"08031\" then\n forcedLearning = true\n end\n\n -- maybe replenish uses on certain cards\n if cardMetadata.uses ~= nil then\n tokenManager.maybeReplenishCard(obj, cardMetadata.uses, self)\n end\n elseif obj.type == \"Deck\" and forcedLearning == false then\n -- check decks for forced learning\n for _, deepObj in ipairs(obj.getObjects()) do\n local cardMetadata = JSON.decode(deepObj.gm_notes) or {}\n if cardMetadata.id == \"08031\" then\n forcedLearning = true\n end\n end\n end\n end\n\n -- flip investigator mini-card and summoned servitor mini-card\n -- (all characters allowed to account for custom IDs - e.g. 'Z0000' for TTS Zoop generated IDs)\n local miniId = string.match(activeInvestigatorId, \".....\") .. \"-m\"\n for _, obj in ipairs(getObjects()) do\n if obj.type == \"Card\" and obj.is_face_down then\n local notes = JSON.decode(obj.getGMNotes())\n if notes ~= nil and notes.type == \"Minicard\" and (notes.id == miniId or notes.id == \"09080-m\") then\n obj.flip()\n end\n end\n end\n\n -- gain a resource (or two if playing Jenny Barnes)\n if string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"02003\" then\n updateCounter({ type = \"ResourceCounter\", modifier = 2 })\n printToColor(\"Gaining 2 resources (Jenny)\", messageColor)\n else\n updateCounter({ type = \"ResourceCounter\", modifier = 1 })\n end\n\n -- draw a card (with handling for Patrice and Forced Learning)\n if activeInvestigatorId == \"06005\" then\n if forcedLearning then\n printToColor(\"Wow, did you really take 'Versatile' to play Patrice with 'Forced Learning'?\"\n .. \" Choose which draw replacement effect takes priority and draw cards accordingly.\", messageColor)\n else\n local handSize = #Player[playerColor].getHandObjects()\n if handSize \u003c 5 then\n local cardsToDraw = 5 - handSize\n printToColor(\"Drawing \" .. cardsToDraw .. \" cards (Patrice)\", messageColor)\n drawCardsWithReshuffle(cardsToDraw)\n end\n end\n elseif forcedLearning then\n printToColor(\"Drawing 2 cards, discard 1 (Forced Learning)\", messageColor)\n drawCardsWithReshuffle(2)\n elseif activeInvestigatorId == \"89001\" then\n printToColor(\"Drawing 2 cards (Subject 5U-21)\", messageColor)\n drawCardsWithReshuffle(2)\n else\n drawCardsWithReshuffle(1)\n end\nend\n\n-- click function for \"draw 1 button\" (that can be added via option panel)\nfunction doDrawOne(_, clickedByColor)\n updateMessageColor(clickedByColor)\n drawCardsWithReshuffle(1)\nend\n\n-- draws the specified amount of cards (and shuffles the discard if necessary)\n---@param numCards number Number of cards to draw\nfunction drawCardsWithReshuffle(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n\n -- Norman Withers handling\n local harbinger = false\n if deckAreaObjects.topCard and deckAreaObjects.topCard.getName() == \"The Harbinger\" then\n harbinger = true\n elseif deckAreaObjects.draw and not deckAreaObjects.draw.is_face_down then\n local cards = deckAreaObjects.draw.getObjects()\n if cards[#cards].name == \"The Harbinger\" then\n harbinger = true\n end\n end\n\n if harbinger then\n printToColor(\"The Harbinger is on top of your deck, not drawing cards\", messageColor)\n return\n end\n\n local topCardDetected = false\n if deckAreaObjects.topCard ~= nil then\n deckAreaObjects.topCard.deal(1, playerColor)\n topCardDetected = true\n numCards = numCards - 1\n if numCards == 0 then\n flipTopCardFromDeck()\n return\n end\n end\n\n local deckSize = 1\n if deckAreaObjects.draw == nil then\n deckSize = 0\n elseif deckAreaObjects.draw.type == \"Deck\" then\n deckSize = #deckAreaObjects.draw.getObjects()\n end\n\n if deckSize \u003e= numCards then\n drawCards(numCards)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n else\n drawCards(deckSize)\n if deckAreaObjects.discard ~= nil then\n shuffleDiscardIntoDeck()\n Wait.time(function()\n drawCards(numCards - deckSize)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n end, 1)\n end\n printToColor(\"Take 1 horror (drawing card from empty deck)\", messageColor)\n end\nend\n\n-- get the draw deck and discard pile objects and returns the references\n---@return table: string-indexed table with references to the found objects\nfunction getDeckAreaObjects()\n local deckAreaObjects = {}\n for _, object in ipairs(searchDeckAndDiscardArea(\"isCardOrDeck\")) do\n if self.positionToLocal(object.getPosition()).z \u003e 0.5 then\n deckAreaObjects.discard = object\n -- Norman Withers handling\n elseif object.type == \"Card\" and not object.is_face_down then\n deckAreaObjects.topCard = object\n else\n deckAreaObjects.draw = object\n end\n end\n return deckAreaObjects\nend\n\n-- draws the specified number of cards (reshuffling of discard pile is handled separately)\n---@param numCards number Number of cards to draw\nfunction drawCards(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.draw then\n deckAreaObjects.draw.deal(numCards, playerColor)\n end\nend\n\nfunction shuffleDiscardIntoDeck()\n local deckAreaObjects = getDeckAreaObjects()\n if not deckAreaObjects.discard.is_face_down then\n deckAreaObjects.discard.flip()\n end\n deckAreaObjects.discard.shuffle()\n deckAreaObjects.discard.setPositionSmooth(self.positionToWorld(DRAW_DECK_POSITION), false, false)\nend\n\n-- utility function for Norman Withers to flip the top card to the revealed side\nfunction flipTopCardFromDeck()\n Wait.time(function()\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.topCard then\n elseif deckAreaObjects.draw then\n if deckAreaObjects.draw.type == \"Card\" then\n deckAreaObjects.draw.flip()\n else\n -- get bounds to know the height of the deck\n local bounds = deckAreaObjects.draw.getBounds()\n local pos = bounds.center + Vector(0, bounds.size.y / 2 + 0.2, 0)\n deckAreaObjects.draw.takeObject({ position = pos, flip = true })\n end\n end\n end, 0.1)\nend\n\n-- discard a random non-hidden card from hand\nfunction doDiscardOne()\n local hand = Player[playerColor].getHandObjects()\n if #hand == 0 then\n broadcastToColor(\"Cannot discard from empty hand!\", messageColor, \"Red\")\n else\n local choices = {}\n for i = 1, #hand do\n local notes = JSON.decode(hand[i].getGMNotes())\n if notes ~= nil then\n if notes.hidden ~= true then\n table.insert(choices, i)\n end\n else\n table.insert(choices, i)\n end\n end\n\n if #choices == 0 then\n broadcastToColor(\"Hidden cards can't be randomly discarded.\", messageColor, \"Orange\")\n return\n end\n\n -- get a random non-hidden card (from the \"choices\" table)\n local num = math.random(1, #choices)\n deckLib.placeOrMergeIntoDeck(hand[choices[num]], returnGlobalDiscardPosition(), self.getRotation())\n\n local playerName = Player[playerColor].steam_name or playerColor\n broadcastToAll(playerName .. \" randomly discarded card \" .. choices[num] .. \"/\" .. #hand .. \".\", \"White\")\n end\nend\n\n---------------------------------------------------------\n-- slot symbol displaying\n---------------------------------------------------------\n\n-- this will redraw the XML for the slot symbols based on the slotData table\nfunction redrawSlotSymbols()\n local xml = {}\n local snapId = 0\n\n -- use the snap point positions in the main play area for positions\n for _, snap in ipairs(self.getSnapPoints()) do\n if inArea(snap.position, MAIN_PLAY_AREA) then\n snapId = snapId + 1\n local slotName = slotData[snapId]\n\n -- conversion from regular coordinates to XML\n local x = snap.position.x * 100\n local y = snap.position.z * 100\n\n -- XML for a single slot (panel with text in the special font)\n local slotXML = {\n tag = \"Panel\",\n attributes = {\n id = \"slotPanel\" .. snapId,\n scale = \"0.1 0.1 1\",\n width = \"175\",\n height = \"175\",\n position = x .. \" \" .. y .. \" -11\"\n },\n children = {\n {\n tag = \"Text\",\n attributes = {\n id = \"slot\" .. snapId,\n rotation = getSlotRotation(slotName),\n fontSize = \"145\",\n font = \"font_arkhamicons\",\n color = \"#414141CB\",\n text = slotNameToChar[slotName]\n }\n }\n }\n }\n table.insert(xml, slotXML)\n end\n end\n\n self.UI.setXmlTable(xml)\nend\n\n-- toggle the \"slot editing mode\"\nfunction toggleSlotEditing(_, clickedByColor, isRightClick)\n if isRightClick then\n resetSlotSymbols()\n return\n end\n\n updateMessageColor(clickedByColor)\n\n -- toggle internal variable\n currentlyEditingSlots = not currentlyEditingSlots\n\n if currentlyEditingSlots then\n editButtonLabel(\"Edit Slots\", \"Stop editing\")\n broadcastToColor(\"Click on a slot symbol (or an empty slot) to edit it.\", messageColor, \"Orange\")\n addClickFunctionToSlots()\n else\n editButtonLabel(\"Stop editing\", \"Edit Slots\")\n redrawSlotSymbols()\n end\nend\n\n-- click function for slot symbols during the \"slot editing mode\"\nfunction slotClickfunction(player, _, id)\n local slotIndex = id:gsub(\"slotPanel\", \"\")\n slotIndex = tonumber(slotIndex)\n\n -- make a list of the table keys as options for the dialog box\n local slotNames = {}\n for slotName, _ in pairs(slotNameToChar) do\n table.insert(slotNames, slotName)\n end\n\n -- prompt player to choose symbol\n player.showOptionsDialog(\"Choose Slot Symbol\", slotNames, slotData[slotIndex],\n function(chosenSlotName)\n slotData[slotIndex] = chosenSlotName\n\n -- update slot symbol\n self.UI.setAttribute(\"slot\" .. slotIndex, \"text\", slotNameToChar[chosenSlotName])\n\n -- update slot rotation\n self.UI.setAttribute(\"slot\" .. slotIndex, \"rotation\", getSlotRotation(chosenSlotName))\n end\n )\nend\n\n-- helper function to rotate the left hand\nfunction getSlotRotation(slotName)\n if slotName == \"Hand (left)\" then\n return \"0 180 180\"\n else\n return \"0 0 180\"\n end\nend\n\n-- reset the slot symbols by making a deep copy of the default data and redrawing\nfunction resetSlotSymbols()\n slotData = {}\n for _, slotName in ipairs(defaultSlotData) do\n table.insert(slotData, slotName)\n end\n\n redrawSlotSymbols()\n\n -- need to re-add the click functions if currently in edit mode\n if currentlyEditingSlots then\n addClickFunctionToSlots()\n end\nend\n\n-- enables the click functions for editing\nfunction addClickFunctionToSlots()\n for i = 1, #slotData do\n self.UI.setAttribute(\"slotPanel\" .. i, \"onClick\", \"slotClickfunction\")\n end\nend\n\n---------------------------------------------------------\n-- color related functions\n---------------------------------------------------------\n\n-- changes the player color\nfunction changeColor(clickedByColor)\n local colorList = Player.getColors()\n\n -- remove existing colors from the list of choices\n for _, existingColor in ipairs(Player.getAvailableColors()) do\n for i, newColor in ipairs(colorList) do\n if existingColor == newColor or newColor == \"Black\" or newColor == \"Grey\" then\n table.remove(colorList, i)\n end\n end\n end\n\n -- show the option dialog for color selection to the player that triggered this\n Player[clickedByColor].showOptionsDialog(\"Select a new color:\", colorList, _, function(color)\n -- update the color of the hand zone\n local handZone = ownedObjects.HandZone\n handZone.setValue(color)\n\n -- if the seated player clicked this, reseat him to the new color\n if clickedByColor == playerColor then\n navigationOverlayApi.copyVisibility(playerColor, color)\n Player[playerColor].changeColor(color)\n end\n\n -- update the internal variable\n playerColor = color\n end)\nend\n\n---------------------------------------------------------\n-- playmat token spawning\n---------------------------------------------------------\n\n-- Finds all customizable cards in this play area and updates their metadata based on the selections\n-- on the matching upgrade sheet.\n-- This method is theoretically O(n^2), and should be used sparingly. In practice it will only be\n-- called when a checkbox is added or removed in-game (which should be rare), and is bounded by the\n-- number of customizable cards in play.\nfunction syncAllCustomizableCards()\n for _, card in ipairs(searchAroundSelf(\"isCard\")) do\n syncCustomizableMetadata(card)\n end\nend\n\nfunction syncCustomizableMetadata(card)\n local cardMetadata = JSON.decode(card.getGMNotes()) or {}\n if cardMetadata == nil or cardMetadata.customizations == nil then return end\n\n for _, upgradeSheet in ipairs(searchAroundSelf(\"isCard\")) do\n local upgradeSheetMetadata = JSON.decode(upgradeSheet.getGMNotes()) or {}\n if upgradeSheetMetadata.id == (cardMetadata.id .. \"-c\") then\n for i, customization in ipairs(cardMetadata.customizations) do\n if customization.replaces ~= nil and customization.replaces.uses ~= nil then\n if upgradeSheet.call(\"isUpgradeActive\", i) then\n cardMetadata.uses = customization.replaces.uses\n card.setGMNotes(JSON.encode(cardMetadata))\n else\n -- TODO: Get the original metadata to restore it... maybe. This should only be\n -- necessary in the very unlikely case that a user un-checks a previously-full upgrade\n -- row while the card is in play. It will be much easier once the AllPlayerCardsApi is\n -- in place, so defer until it is\n end\n end\n end\n end\n end\nend\n\nfunction spawnTokensFor(object)\n local extraUses = {}\n if activeInvestigatorId == \"03004\" then\n extraUses[\"Charge\"] = 1\n end\n\n tokenManager.spawnForCard(object, extraUses)\nend\n\nfunction onCollisionEnter(collisionInfo)\n local object = collisionInfo.collision_object\n\n -- only continue if loading is completed\n if not collisionEnabled then return end\n\n -- only continue for cards\n if object.type ~= \"Card\" then return end\n\n -- detect if \"Dream-Enhancing Serum\" is placed\n if object.getName() == \"Dream-Enhancing Serum\" then isDES = true end\n\n maybeUpdateActiveInvestigator(object)\n syncCustomizableMetadata(object)\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n elseif shouldSpawnTokens(object) then\n spawnTokensFor(object)\n end\nend\n\n-- detect if \"Dream-Enhancing Serum\" is removed\nfunction onCollisionExit(collisionInfo)\n if collisionInfo.collision_object.getName() == \"Dream-Enhancing Serum\" then isDES = false end\nend\n\n-- checks if tokens should be spawned for the provided card\nfunction shouldSpawnTokens(card)\n if card.is_face_down then\n return false\n end\n\n local localCardPos = self.positionToLocal(card.getPosition())\n local metadata = JSON.decode(card.getGMNotes())\n\n -- If no metadata we don't know the type, so only spawn in the main area\n if metadata == nil then\n return inArea(localCardPos, MAIN_PLAY_AREA)\n end\n\n -- Spawn tokens for assets and events on the main area\n if inArea(localCardPos, MAIN_PLAY_AREA)\n and (metadata.type == \"Asset\"\n or metadata.type == \"Event\") then\n return true\n end\n\n -- Spawn tokens for all encounter types in the threat area\n if inArea(localCardPos, THREAT_AREA)\n and (metadata.type == \"Treachery\"\n or metadata.type == \"Enemy\"\n or metadata.weakness) then\n return true\n end\n\n return false\nend\n\nfunction onObjectEnterContainer(container, object)\n if object.type ~= \"Card\" then return end\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n end\nend\n\n-- removes tokens from the provided card/deck\nfunction removeTokensFromObject(object)\n if object.hasTag(\"CardThatSeals\") then\n local func = object.getVar(\"resetSealedTokens\") -- check if function exists (it won't for older custom content)\n if func ~= nil then\n object.call(\"resetSealedTokens\")\n end\n end\n\n for _, obj in ipairs(searchLib.onObject(object)) do\n if tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n elseif obj.getGUID() ~= \"4ee1f2\" and -- table\n obj ~= self and\n obj.type ~= \"Deck\" and\n obj.type ~= \"Card\" and\n obj.memo ~= nil and\n obj.getLock() == false and\n obj.getDescription() ~= \"Action Token\" then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n---------------------------------------------------------\n-- investigator ID grabbing and skill tracker\n---------------------------------------------------------\n\n-- updates the internal investigator id and action tokens if an investigator card is detected\n---@param card tts__Object Card that might be an investigator\nfunction maybeUpdateActiveInvestigator(card)\n if not inArea(self.positionToLocal(card.getPosition()), INVESTIGATOR_AREA) then return end\n\n local notes = JSON.decode(card.getGMNotes())\n local class\n\n if notes ~= nil and notes.type == \"Investigator\" and notes.id ~= nil then\n if notes.id == activeInvestigatorId then return end\n class = notes.class\n activeInvestigatorId = notes.id\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", {\n notes.willpowerIcons,\n notes.intellectIcons,\n notes.combatIcons,\n notes.agilityIcons\n })\n elseif activeInvestigatorId ~= \"00000\" then\n class = \"Neutral\"\n activeInvestigatorId = \"00000\"\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", { 1, 1, 1, 1 })\n else\n return\n end\n\n -- change state of action tokens\n local search = searchArea(self.positionToWorld({ -1.1, 0.05, -0.27 }), { 4, 1, 1 })\n local smallToken = nil\n local STATE_TABLE = {\n [\"Guardian\"] = 1,\n [\"Seeker\"] = 2,\n [\"Rogue\"] = 3,\n [\"Mystic\"] = 4,\n [\"Survivor\"] = 5,\n [\"Neutral\"] = 6\n }\n\n for _, obj in ipairs(search) do\n if obj.getDescription() == \"Action Token\" and obj.getStateId() \u003e 0 then\n if obj.getScale().x \u003c 0.4 then\n smallToken = obj\n else\n setObjectState(obj, STATE_TABLE[class])\n end\n end\n end\n\n -- update the small token with special action for certain investigators\n local SPECIAL_ACTIONS = {\n [\"04002\"] = 8, -- Ursula Downs\n [\"01002\"] = 9, -- Daisy Walker\n [\"01502\"] = 9, -- Daisy Walker\n [\"01002-pb\"] = 9, -- Daisy Walker\n [\"06003\"] = 10, -- Tony Morgan\n [\"04003\"] = 11, -- Finn Edwards\n [\"08016\"] = 14 -- Bob Jenkins\n }\n\n if smallToken ~= nil then\n setObjectState(smallToken, SPECIAL_ACTIONS[activeInvestigatorId] or STATE_TABLE[class])\n end\nend\n\nfunction setObjectState(obj, stateId)\n if obj.getStateId() ~= stateId then obj.setState(stateId) end\nend\n\n---------------------------------------------------------\n-- manipulation of owned objects\n---------------------------------------------------------\n\n-- updates the specified owned counter\n---@param param table Contains the information to update:\n--- type: String Counter to target\n--- newValue: Number Value to set the counter to\n--- modifier: Number If newValue is not provided, the existing value will be adjusted by this modifier\nfunction updateCounter(param)\n local counter = ownedObjects[param.type]\n if counter ~= nil then\n counter.call(\"updateVal\", param.newValue or (counter.getVar(\"val\") + param.modifier))\n else\n printToAll(param.type .. \" for \" .. matColor .. \" could not be found.\", \"Yellow\")\n end\nend\n\n-- get the value the specified owned counter\n---@param type string Counter to target\n---@return number: Counter value\nfunction getCounterValue(type)\n return ownedObjects[type].getVar(\"val\")\nend\n\n-- set investigator skill tracker to \"1, 1, 1, 1\"\nfunction resetSkillTracker()\n local obj = ownedObjects.InvestigatorSkillTracker\n if obj ~= nil then\n obj.call(\"updateStats\", { 1, 1, 1, 1 })\n else\n printToAll(\"Skill tracker for \" .. matColor .. \" playmat could not be found.\", \"Yellow\")\n end\nend\n\n---------------------------------------------------------\n-- calls to 'Global' / functions for calls from outside\n---------------------------------------------------------\n\nfunction drawChaosTokenButton(_, _, isRightClick)\n chaosBagApi.drawChaosToken(self, isRightClick)\nend\n\nfunction drawEncounterCard(_, _, isRightClick)\n local drawPos = getEncounterCardDrawPosition(not isRightClick)\n mythosAreaApi.drawEncounterCard(matColor, drawPos)\nend\n\nfunction returnGlobalDiscardPosition()\n return self.positionToWorld(DISCARD_PILE_POSITION)\nend\n\nfunction returnGlobalDrawPosition()\n return self.positionToWorld(DRAW_DECK_POSITION)\nend\n\n-- returns the position for encounter card drawing\n---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\nfunction getEncounterCardDrawPosition(stack)\n local drawPos = self.positionToWorld(DRAWN_ENCOUNTER_POSITION)\n\n -- maybe override position with first empty slot in threat area (right to left)\n if not stack then\n local searchPos = Vector(-0.91, 0.5, -0.625)\n for i = 1, 5 do\n local globalSearchPos = self.positionToWorld(searchPos)\n local searchResult = searchLib.atPosition(globalSearchPos, \"isCardOrDeck\")\n if #searchResult == 0 then\n drawPos = globalSearchPos\n break\n else\n searchPos.x = searchPos.x + 0.455\n end\n end\n end\n\n return drawPos\nend\n\n-- creates / removes the draw 1 button\n---@param visible boolean Whether the draw 1 button should be visible\nfunction showDrawButton(visible)\n isDrawButtonVisible = visible\n\n if isDrawButtonVisible then\n -- Draw 1 button: modified default data\n buttonParameters.label = \"Draw 1\"\n buttonParameters.click_function = \"doDrawOne\"\n buttonParameters.tooltip = \"\"\n buttonParameters.position.z = -0.35\n self.createButton(buttonParameters)\n else\n local buttons = self.getButtons()\n for i = 1, #buttons do\n if buttons[i].label == \"Draw 1\" then\n self.removeButton(buttons[i].index)\n end\n end\n end\nend\n\n-- shows / hides a clickable clue counter for this playmat and sets the correct amount of clues\n---@param showCounter boolean Whether the clickable clue counter should be visible\nfunction clickableClues(showCounter)\n local clickerPos = ownedObjects.ClickableClueCounter.getPosition()\n local clueCount = 0\n\n -- move clue counters\n local modY = showCounter and 0.525 or -0.525\n ownedObjects.ClickableClueCounter.setPosition(clickerPos + Vector(0, modY, 0))\n\n if showCounter then\n -- get current clue count\n clueCount = ownedObjects.ClueCounter.getVar(\"exposedValue\")\n\n -- remove clues\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n\n -- set value for clue clickers\n ownedObjects.ClickableClueCounter.call(\"updateVal\", clueCount)\n else\n -- get current clue count\n clueCount = ownedObjects.ClickableClueCounter.getVar(\"val\")\n\n -- spawn clues\n local pos = self.positionToWorld({ x = -1.12, y = 0.05, z = 0.7 })\n for i = 1, clueCount do\n pos.y = pos.y + 0.045 * i\n tokenManager.spawnToken(pos, \"clue\", self.getRotation())\n end\n end\nend\n\n-- removes all clues (moving tokens to the trash and setting counters to 0)\nfunction removeClues()\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n ownedObjects.ClickableClueCounter.call(\"updateVal\", 0)\nend\n\n-- reports the clue count\n---@param useClickableCounters boolean Controls which type of counter is getting checked\nfunction getClueCount(useClickableCounters)\n if useClickableCounters then\n return ownedObjects.ClickableClueCounter.getVar(\"val\")\n else\n return ownedObjects.ClueCounter.getVar(\"exposedValue\")\n end\nend\n\n-- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes\n-- is true, the main card slot snap points will only snap assets, while the investigator area point\n-- will only snap Investigators. If matchTypes is false, snap points will be reset to snap all cards.\n---@param matchTypes boolean Whether snap points should only snap for the matching card types.\nfunction setLimitSnapsByType(matchTypes)\n local snaps = self.getSnapPoints()\n for i, snap in ipairs(snaps) do\n if inArea(snap.position, MAIN_PLAY_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Asset\" }\n else\n table.insert(snaps[i].tags, \"Asset\")\n end\n else\n snaps[i].tags = nil\n end\n end\n if inArea(snap.position, INVESTIGATOR_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Investigator\" }\n else\n table.insert(snaps[i].tags, \"Investigator\")\n end\n else\n snaps[i].tags = nil\n end\n end\n end\n self.setSnapPoints(snaps)\nend\n\n-- Simple method to check if the given point is in a specified area. Local use only\n---@param point tts__Vector Point to check, only x and z values are relevant\n---@param bounds table Defined area to see if the point is within. See MAIN_PLAY_AREA for sample bounds definition.\n---@return boolean: True if the point is in the area defined by bounds\nfunction inArea(point, bounds)\n return (point.x \u003c bounds.upperLeft.x\n and point.x \u003e bounds.lowerRight.x\n and point.z \u003c bounds.upperLeft.z\n and point.z \u003e bounds.lowerRight.z)\nend\n\n-- called by custom data helpers to add player card data\n---@param args table Contains only one entry, the GUID of the custom data helper\nfunction updatePlayerCards(args)\n local customDataHelper = getObjectFromGUID(args[1])\n local playerCardData = customDataHelper.getTable(\"PLAYER_CARD_DATA\")\n tokenManager.addPlayerCardData(playerCardData)\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/token/TokenChecker\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local CHAOS_TOKEN_NAMES = {\n [\"Elder Sign\"] = true,\n [\"+1\"] = true,\n [\"0\"] = true,\n [\"-1\"] = true,\n [\"-2\"] = true,\n [\"-3\"] = true,\n [\"-4\"] = true,\n [\"-5\"] = true,\n [\"-6\"] = true,\n [\"-7\"] = true,\n [\"-8\"] = true,\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n [\"Auto-fail\"] = true,\n [\"Bless\"] = true,\n [\"Curse\"] = true,\n [\"Frost\"] = true\n }\n\n local TokenChecker = {}\n\n -- returns true if the passed object is a chaos token (by name)\n TokenChecker.isChaosToken = function(obj)\n if obj.type == \"Tile\" and CHAOS_TOKEN_NAMES[obj.getName()] then\n return true\n else\n return false\n end\n end\n\n return TokenChecker\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/Playmat\")\nend)\nreturn __bundle_require(\"__root\")", + "LuaScriptState": "{\"activeInvestigatorId\":\"00000\",\"isDrawButtonVisible\":false,\"playerColor\":\"White\",\"slotData\":[\"any\",\"any\",\"any\",\"Tarot\",\"Hand (left)\",\"Hand (right)\",\"Ally\",\"any\",\"any\",\"any\",\"Accessory\",\"Arcane\",\"Arcane\",\"Body\"]}", "MeasureMovement": false, "Memo": "White", "Name": "Custom_Tile", @@ -50737,9 +50747,9 @@ }, { "Position": { - "x": -0.631, + "x": 1.758, "y": 0.1, - "z": 0.551 + "z": 0.04 }, "Tags": [ "Asset" @@ -50747,39 +50757,9 @@ }, { "Position": { - "x": -0.616, - "y": 0.102, - "z": 0.024 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": -0.177, - "y": 0.101, - "z": 0.032 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": -0.174, - "y": 0.099, - "z": 0.551 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": 0.212, + "x": 1.371, "y": 0.1, - "z": 0.559 + "z": 0.038 }, "Tags": [ "Asset" @@ -50787,7 +50767,7 @@ }, { "Position": { - "x": 0.217, + "x": 0.98, "y": 0.1, "z": 0.035 }, @@ -50807,28 +50787,8 @@ }, { "Position": { - "x": 0.605, + "x": 0.217, "y": 0.1, - "z": 0.555 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": 0.977, - "y": 0.099, - "z": 0.556 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": 0.98, - "y": 0.099, "z": 0.035 }, "Tags": [ @@ -50837,9 +50797,9 @@ }, { "Position": { - "x": 1.371, + "x": -0.177, "y": 0.1, - "z": 0.038 + "z": 0.032 }, "Tags": [ "Asset" @@ -50847,9 +50807,9 @@ }, { "Position": { - "x": 1.371, - "y": 0.099, - "z": 0.558 + "x": -0.616, + "y": 0.1, + "z": 0.024 }, "Tags": [ "Asset" @@ -50867,9 +50827,59 @@ }, { "Position": { - "x": 1.758, - "y": 0.101, - "z": 0.04 + "x": 1.371, + "y": 0.1, + "z": 0.558 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": 0.977, + "y": 0.1, + "z": 0.556 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": 0.605, + "y": 0.1, + "z": 0.555 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": 0.212, + "y": 0.1, + "z": 0.559 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": -0.174, + "y": 0.1, + "z": 0.551 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": -0.631, + "y": 0.1, + "z": 0.551 }, "Tags": [ "Asset" @@ -51009,7 +51019,7 @@ }, "ImageScalar": 1, "ImageSecondaryURL": "", - "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037357630681963618/E7271737B19CE0BFAAA382BEEEF497FE3E06ECC1/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/", "WidthScale": 0 }, "Description": "", @@ -51023,8 +51033,8 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/Playmat\")\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat\n ---@param mat tts__Object Playermat that triggered this\n ---@param alwaysFaceUp boolean Whether the card should be drawn face-up\n MythosAreaApi.drawEncounterCard = function(mat, alwaysFaceUp)\n getMythosArea().call(\"drawEncounterCard\", {mat = mat, alwaysFaceUp = alwaysFaceUp})\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"core/NavigationOverlayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local NavigationOverlayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getNOHandler()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"NavigationOverlayHandler\")\n end\n\n -- copies the visibility for the Navigation overlay\n ---@param startColor string Color of the player to copy from\n ---@param targetColor string Color of the targeted player\n NavigationOverlayApi.copyVisibility = function(startColor, targetColor)\n getNOHandler().call(\"copyVisibility\", {\n startColor = startColor,\n targetColor = targetColor\n })\n end\n\n -- changes the Navigation Overlay view (\"Full View\" --\u003e \"Play Areas\" --\u003e \"Closed\" etc.)\n ---@param playerColor string Color of the player to update the visibility for\n NavigationOverlayApi.cycleVisibility = function(playerColor)\n getNOHandler().call(\"cycleVisibility\", playerColor)\n end\n\n -- loads the specified camera for a player\n ---@param player tts__Player Player whose camera should be moved\n ---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to\n NavigationOverlayApi.loadCamera = function(player, camera)\n getNOHandler().call(\"loadCameraFromApi\", {\n player = player,\n camera = camera\n })\n end\n\n return NavigationOverlayApi\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/token/TokenChecker\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local CHAOS_TOKEN_NAMES = {\n [\"Elder Sign\"] = true,\n [\"+1\"] = true,\n [\"0\"] = true,\n [\"-1\"] = true,\n [\"-2\"] = true,\n [\"-3\"] = true,\n [\"-4\"] = true,\n [\"-5\"] = true,\n [\"-6\"] = true,\n [\"-7\"] = true,\n [\"-8\"] = true,\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n [\"Auto-fail\"] = true,\n [\"Bless\"] = true,\n [\"Curse\"] = true,\n [\"Frost\"] = true\n }\n\n local TokenChecker = {}\n\n -- returns true if the passed object is a chaos token (by name)\n TokenChecker.isChaosToken = function(obj)\n if obj.type == \"Tile\" and CHAOS_TOKEN_NAMES[obj.getName()] then\n return true\n else\n return false\n end\n end\n\n return TokenChecker\nend\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror\n -- tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned) spawned.setState(tokenValue) end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"playermat/Playmat\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal deckLib = require(\"util/DeckLib\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal navigationOverlayApi = require(\"core/NavigationOverlayApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenChecker = require(\"core/token/TokenChecker\")\nlocal tokenManager = require(\"core/token/TokenManager\")\n\n-- we use this to turn off collision handling until onLoad() is complete\nlocal collisionEnabled = false\n\n-- x-Values for discard buttons\nlocal DISCARD_BUTTON_OFFSETS = {-1.365, -0.91, -0.455, 0, 0.455, 0.91}\n\nlocal SEARCH_AROUND_SELF_X_BUFFER = 8\n\n-- defined areas for object searching\nlocal MAIN_PLAY_AREA = {\n upperLeft = {\n x = 1.98,\n z = 0.736\n },\n lowerRight = {\n x = -0.79,\n z = -0.39\n }\n}\nlocal INVESTIGATOR_AREA = {\n upperLeft = {\n x = -1.084,\n z = 0.06517\n },\n lowerRight = {\n x = -1.258,\n z = -0.0805\n }\n}\nlocal THREAT_AREA = {\n upperLeft = {\n x = 1.53,\n z = -0.34\n },\n lowerRight = {\n x = -1.13,\n z = -0.92\n }\n}\nlocal DECK_DISCARD_AREA = {\n upperLeft = {\n x = -1.62,\n z = 0.855\n },\n lowerRight = {\n x = -2.02,\n z = -0.245\n },\n center = {\n x = -1.82,\n y = 0.5,\n z = 0.305\n },\n size = {\n x = 0.4,\n y = 3,\n z = 1.1\n }\n}\n\n-- local position of draw and discard pile\nlocal DRAW_DECK_POSITION = { x = -1.82, y = 0.1, z = 0 }\nlocal DISCARD_PILE_POSITION = { x = -1.82, y = 0.1, z = 0.61 }\n\n-- global position of encounter discard pile\nlocal ENCOUNTER_DISCARD_POSITION = { x = -3.85, y = 1.5, z = 10.38}\n\n-- global variable so it can be reset by the Clean Up Helper\nactiveInvestigatorId = \"00000\"\n\n-- table of type-object reference pairs of all owned objects\nlocal ownedObjects = {}\nlocal matColor = self.getMemo()\n\n-- variable to track the status of the \"Show Draw Button\" option\nlocal isDrawButtonVisible = false\n\n-- global variable to report \"Dream-Enhancing Serum\" status\nisDES = false\n\nfunction onSave()\n return JSON.encode({\n playerColor = playerColor,\n activeInvestigatorId = activeInvestigatorId,\n isDrawButtonVisible = isDrawButtonVisible\n })\nend\n\nfunction onLoad(saveState)\n self.interactable = false\n\n -- get object references to owned objects\n ownedObjects = guidReferenceApi.getObjectsByOwner(matColor)\n\n -- button creation\n for i = 1, 6 do\n makeDiscardButton(DISCARD_BUTTON_OFFSETS[i], i)\n end\n\n self.createButton({\n click_function = \"drawEncounterCard\",\n function_owner = self,\n position = {-1.84, 0, -0.65},\n rotation = {0, 80, 0},\n width = 265,\n height = 190\n })\n\n self.createButton({\n click_function = \"drawChaosTokenButton\",\n function_owner = self,\n position = {1.85, 0, -0.74},\n rotation = {0, -45, 0},\n width = 135,\n height = 135\n })\n\n self.createButton({\n label = \"Upkeep\",\n click_function = \"doUpkeep\",\n function_owner = self,\n position = {1.84, 0.1, -0.44},\n scale = {0.12, 0.12, 0.12},\n width = 800,\n height = 280,\n font_size = 180\n })\n\n -- save state loading\n local state = JSON.decode(saveState)\n if state ~= nil then\n playerColor = state.playerColor\n activeInvestigatorId = state.activeInvestigatorId\n isDrawButtonVisible = state.isDrawButtonVisible\n end\n\n showDrawButton(isDrawButtonVisible)\n math.randomseed(os.time())\n Wait.time(function() collisionEnabled = true end, 0.1)\nend\n\n---------------------------------------------------------\n-- utility functions\n---------------------------------------------------------\n\n-- searches an area and optionally filters the result\nfunction searchArea(origin, size, filter)\n return searchLib.inArea(origin, self.getRotation(), size, filter)\nend\n\n-- finds all objects on the playmat and associated set aside zone.\nfunction searchAroundSelf(filter)\n local bounds = self.getBoundsNormalized()\n -- Increase the width to cover the set aside zone\n bounds.size.x = bounds.size.x + SEARCH_AROUND_SELF_X_BUFFER\n bounds.size.y = 1\n -- Since the cast is centered on the position, shift left or right to keep the non-set aside edge\n -- of the cast at the edge of the playmat\n -- setAsideDirection accounts for the set aside zone being on the left or right, depending on the\n -- table position of the playmat\n local setAsideDirection = bounds.center.z \u003e 0 and 1 or -1\n local localCenter = self.positionToLocal(bounds.center)\n localCenter.x = localCenter.x + setAsideDirection * SEARCH_AROUND_SELF_X_BUFFER / 2 / self.getScale().x\n return searchArea(self.positionToWorld(localCenter), bounds.size, filter)\nend\n\n-- searches the area around the draw deck and discard pile\nfunction searchDeckAndDiscardArea(filter)\n local pos = self.positionToWorld(DECK_DISCARD_AREA.center)\n local scale = self.getScale()\n local size = {\n x = DECK_DISCARD_AREA.size.x * scale.x,\n y = DECK_DISCARD_AREA.size.y, \n z = DECK_DISCARD_AREA.size.z * scale.z\n }\n return searchArea(pos, size, filter)\nend\n\nfunction doNotReady(card)\n return card.getVar(\"do_not_ready\") or false\nend\n\n-- rounds a number to the specified amount of decimal places\n---@param num number Initial value\n---@param numDecimalPlaces number Amount of decimal places\nfunction round(num, numDecimalPlaces)\n local mult = 10^(numDecimalPlaces or 0)\n return math.floor(num * mult + 0.5) / mult\nend\n\n---------------------------------------------------------\n-- Discard buttons\n---------------------------------------------------------\n\n-- handles discarding for a list of objects\n---@param objList table List of objects to discard\nfunction discardListOfObjects(objList)\n for _, obj in ipairs(objList) do\n if obj.type == \"Card\" or obj.type == \"Deck\" then\n if obj.hasTag(\"PlayerCard\") then\n deckLib.placeOrMergeIntoDeck(obj, returnGlobalDiscardPosition(), self.getRotation())\n else\n deckLib.placeOrMergeIntoDeck(obj, ENCOUNTER_DISCARD_POSITION, {x = 0, y = -90, z = 0})\n end\n -- put chaos tokens back into bag (e.g. Unrelenting)\n elseif tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n -- don't touch locked objects (like the table etc.)\n elseif not obj.getLock() then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n-- build a discard button to discard from searchPosition (number must be unique)\nfunction makeDiscardButton(xValue, number)\n local position = { xValue, 0.1, -0.94}\n local searchPosition = {-position[1], position[2], position[3] + 0.32}\n local handlerName = 'handler' .. number\n self.setVar(handlerName, function()\n local cardSizeSearch = {2, 1, 3.2}\n local globalSearchPosition = self.positionToWorld(searchPosition)\n local searchResult = searchArea(globalSearchPosition, cardSizeSearch)\n return discardListOfObjects(searchResult)\n end)\n self.createButton({\n label = \"Discard\",\n click_function = handlerName,\n function_owner = self,\n position = position,\n scale = {0.12, 0.12, 0.12},\n width = 900,\n height = 350,\n font_size = 220\n })\nend\n\n---------------------------------------------------------\n-- Upkeep button\n---------------------------------------------------------\n\n-- calls the Upkeep function with correct parameter\nfunction doUpkeepFromHotkey(color)\n doUpkeep(_, color)\nend\n\nfunction doUpkeep(_, clickedByColor, isRightClick)\n if isRightClick then\n changeColor(clickedByColor)\n return\n end\n\n -- send messages to player who clicked button if no seated player found\n messageColor = Player[playerColor].seated and playerColor or clickedByColor\n\n -- unexhaust cards in play zone, flip action tokens and find forcedLearning\n local forcedLearning = false\n local rot = self.getRotation()\n for _, obj in ipairs(searchAroundSelf()) do\n if obj.getDescription() == \"Action Token\" and obj.is_face_down then\n obj.flip()\n elseif obj.type == \"Card\" and not inArea(self.positionToLocal(obj.getPosition()), INVESTIGATOR_AREA) then\n local cardMetadata = JSON.decode(obj.getGMNotes()) or {}\n if not doNotReady(obj) then\n local cardRotation = round(obj.getRotation().y, 0) - rot.y\n local yRotDiff = 0\n\n if cardRotation \u003c 0 then\n cardRotation = cardRotation + 360\n end\n\n -- rotate cards to the next multiple of 90° towards 0°\n if cardRotation \u003e 90 and cardRotation \u003c= 180 then\n yRotDiff = 90\n elseif cardRotation \u003c 270 and cardRotation \u003e 180 then\n yRotDiff = 270\n end\n\n -- set correct rotation for face-down cards\n rot.z = obj.is_face_down and 180 or 0\n obj.setRotation({rot.x, rot.y + yRotDiff, rot.z})\n end\n if cardMetadata.id == \"08031\" then\n forcedLearning = true\n end\n if cardMetadata.uses ~= nil then\n tokenManager.maybeReplenishCard(obj, cardMetadata.uses, self)\n end\n end\n end\n\n -- flip investigator mini-card and summoned servitor mini-card\n -- (all characters allowed to account for custom IDs - e.g. 'Z0000' for TTS Zoop generated IDs)\n local miniId = string.match(activeInvestigatorId, \".....\") .. \"-m\"\n for _, obj in ipairs(getObjects()) do\n if obj.type == \"Card\" and obj.is_face_down then\n local notes = JSON.decode(obj.getGMNotes())\n if notes ~= nil and notes.type == \"Minicard\" and (notes.id == miniId or notes.id == \"09080-m\") then\n obj.flip()\n end\n end\n end\n\n -- gain a resource (or two if playing Jenny Barnes)\n if string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"02003\" then\n updateCounter({type = \"ResourceCounter\", modifier = 2})\n printToColor(\"Gaining 2 resources (Jenny)\", messageColor)\n else\n updateCounter({type = \"ResourceCounter\", modifier = 1})\n end\n\n -- draw a card (with handling for Patrice and Forced Learning)\n if activeInvestigatorId == \"06005\" then\n if forcedLearning then\n printToColor(\"Wow, did you really take 'Versatile' to play Patrice with 'Forced Learning'? Choose which draw replacement effect takes priority and draw cards accordingly.\", messageColor)\n else\n local handSize = #Player[playerColor].getHandObjects()\n if handSize \u003c 5 then\n local cardsToDraw = 5 - handSize\n printToColor(\"Drawing \" .. cardsToDraw .. \" cards (Patrice)\", messageColor)\n drawCardsWithReshuffle(cardsToDraw)\n end\n end\n elseif forcedLearning then\n printToColor(\"Drawing 2 cards, discard 1 (Forced Learning)\", messageColor)\n drawCardsWithReshuffle(2)\n elseif activeInvestigatorId == \"89001\" then\n printToColor(\"Drawing 2 cards (Subject 5U-21)\", messageColor)\n drawCardsWithReshuffle(2)\n else\n drawCardsWithReshuffle(1)\n end\nend\n\n-- function for \"draw 1 button\" (that can be added via option panel)\nfunction doDrawOne(_, color)\n -- send messages to player who clicked button if no seated player found\n messageColor = Player[playerColor].seated and playerColor or color\n drawCardsWithReshuffle(1)\nend\n\n-- draw X cards (shuffle discards if necessary)\nfunction drawCardsWithReshuffle(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n\n -- Norman Withers handling\n local harbinger = false\n if deckAreaObjects.topCard and deckAreaObjects.topCard.getName() == \"The Harbinger\" then\n harbinger = true\n elseif deckAreaObjects.draw and not deckAreaObjects.draw.is_face_down then\n local cards = deckAreaObjects.draw.getObjects()\n if cards[#cards].name == \"The Harbinger\" then\n harbinger = true\n end\n end\n\n if harbinger then\n printToColor(\"The Harbinger is on top of your deck, not drawing cards\", messageColor)\n return\n end\n\n local topCardDetected = false\n if deckAreaObjects.topCard ~= nil then\n deckAreaObjects.topCard.deal(1, playerColor)\n topCardDetected = true\n numCards = numCards - 1\n if numCards == 0 then\n flipTopCardFromDeck()\n return\n end\n end\n\n local deckSize = 1\n if deckAreaObjects.draw == nil then\n deckSize = 0\n elseif deckAreaObjects.draw.type == \"Deck\" then\n deckSize = #deckAreaObjects.draw.getObjects()\n end\n\n if deckSize \u003e= numCards then\n drawCards(numCards)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n else\n drawCards(deckSize)\n if deckAreaObjects.discard ~= nil then\n shuffleDiscardIntoDeck()\n Wait.time(function()\n drawCards(numCards - deckSize)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n end, 1)\n end\n printToColor(\"Take 1 horror (drawing card from empty deck)\", messageColor)\n end\nend\n\n-- get the draw deck and discard pile objects and returns the references\nfunction getDeckAreaObjects()\n local deckAreaObjects = {}\n for _, object in ipairs(searchDeckAndDiscardArea(\"isCardOrDeck\")) do\n if self.positionToLocal(object.getPosition()).z \u003e 0.5 then\n deckAreaObjects.discard = object\n -- Norman Withers handling\n elseif object.type == \"Card\" and not object.is_face_down then\n deckAreaObjects.topCard = object\n else\n deckAreaObjects.draw = object\n end\n end\n return deckAreaObjects\nend\n\nfunction drawCards(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.draw then\n deckAreaObjects.draw.deal(numCards, playerColor)\n end\nend\n\nfunction shuffleDiscardIntoDeck()\n local deckAreaObjects = getDeckAreaObjects()\n if not deckAreaObjects.discard.is_face_down then\n deckAreaObjects.discard.flip()\n end\n deckAreaObjects.discard.shuffle()\n deckAreaObjects.discard.setPositionSmooth(self.positionToWorld(DRAW_DECK_POSITION), false, false)\nend\n\n-- utility function for Norman Withers to flip the top card to the revealed side\nfunction flipTopCardFromDeck()\n Wait.time(function()\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.topCard then\n elseif deckAreaObjects.draw then\n if deckAreaObjects.draw.type == \"Card\" then\n deckAreaObjects.draw.flip()\n else\n -- get bounds to know the height of the deck\n local bounds = deckAreaObjects.draw.getBounds()\n local pos = bounds.center + Vector(0, bounds.size.y / 2 + 0.2, 0)\n deckAreaObjects.draw.takeObject({ position = pos, flip = true })\n end\n end\n end, 0.1)\nend\n\n-- discard a random non-hidden card from hand\nfunction doDiscardOne()\n local hand = Player[playerColor].getHandObjects()\n if #hand == 0 then\n broadcastToAll(\"Cannot discard from empty hand!\", \"Red\")\n else\n local choices = {}\n for i = 1, #hand do\n local notes = JSON.decode(hand[i].getGMNotes())\n if notes ~= nil then\n if notes.hidden ~= true then\n table.insert(choices, i)\n end\n else\n table.insert(choices, i)\n end\n end\n\n if #choices == 0 then\n broadcastToAll(\"Hidden cards can't be randomly discarded.\", \"Orange\")\n return\n end\n\n -- get a random non-hidden card (from the \"choices\" table)\n local num = math.random(1, #choices)\n deckLib.placeOrMergeIntoDeck(hand[choices[num]], returnGlobalDiscardPosition(), self.getRotation())\n\n local playerName = Player[playerColor].steam_name or playerColor\n broadcastToAll(playerName .. \" randomly discarded card \" .. choices[num] .. \"/\" .. #hand .. \".\", \"White\")\n end\nend\n\n---------------------------------------------------------\n-- color related functions\n---------------------------------------------------------\n\n-- changes the player color\nfunction changeColor(clickedByColor)\n local colorList = {\n \"White\",\n \"Brown\",\n \"Red\",\n \"Orange\",\n \"Yellow\",\n \"Green\",\n \"Teal\",\n \"Blue\",\n \"Purple\",\n \"Pink\"\n }\n\n -- remove existing colors from the list of choices\n for _, existingColor in ipairs(Player.getAvailableColors()) do\n for i, newColor in ipairs(colorList) do\n if existingColor == newColor then\n table.remove(colorList, i)\n end\n end\n end\n\n -- show the option dialog for color selection to the player that triggered this\n Player[clickedByColor].showOptionsDialog(\"Select a new color:\", colorList, _, function(color)\n -- update the color of the hand zone\n local handZone = ownedObjects.HandZone\n handZone.setValue(color)\n\n -- if the seated player clicked this, reseat him to the new color\n if clickedByColor == playerColor then\n navigationOverlayApi.copyVisibility(playerColor, color)\n Player[playerColor].changeColor(color)\n end\n\n -- update the internal variable\n playerColor = color\n end)\nend\n\n---------------------------------------------------------\n-- playmat token spawning\n---------------------------------------------------------\n\n-- Finds all customizable cards in this play area and updates their metadata based on the selections\n-- on the matching upgrade sheet.\n-- This method is theoretically O(n^2), and should be used sparingly. In practice it will only be\n-- called when a checkbox is added or removed in-game (which should be rare), and is bounded by the\n-- number of customizable cards in play.\nfunction syncAllCustomizableCards()\n for _, card in ipairs(searchAroundSelf(\"isCard\")) do\n syncCustomizableMetadata(card)\n end\nend\n\nfunction syncCustomizableMetadata(card)\n local cardMetadata = JSON.decode(card.getGMNotes()) or { }\n if cardMetadata == nil or cardMetadata.customizations == nil then\n return\n end\n for _, upgradeSheet in ipairs(searchAroundSelf(\"isCard\")) do\n local upgradeSheetMetadata = JSON.decode(upgradeSheet.getGMNotes()) or { }\n if upgradeSheetMetadata.id == (cardMetadata.id .. \"-c\") then\n for i, customization in ipairs(cardMetadata.customizations) do\n if customization.replaces ~= nil and customization.replaces.uses ~= nil then\n -- Allowed use of call(), no APIs for individual cards\n if upgradeSheet.call(\"isUpgradeActive\", i) then\n cardMetadata.uses = customization.replaces.uses\n card.setGMNotes(JSON.encode(cardMetadata))\n else\n -- TODO: Get the original metadata to restore it... maybe. This should only be\n -- necessary in the very unlikely case that a user un-checks a previously-full upgrade\n -- row while the card is in play. It will be much easier once the AllPlayerCardsApi is\n -- in place, so defer until it is\n end\n end\n end\n end\n end\nend\n\nfunction spawnTokensFor(object)\n local extraUses = { }\n if activeInvestigatorId == \"03004\" then\n extraUses[\"Charge\"] = 1\n end\n\n tokenManager.spawnForCard(object, extraUses)\nend\n\nfunction onCollisionEnter(collisionInfo)\n local object = collisionInfo.collision_object\n\n -- only continue if loading is completed\n if not collisionEnabled then return end\n\n -- only continue for cards\n if object.type ~= \"Card\" then return end\n\n -- detect if \"Dream-Enhancing Serum\" is placed\n if object.getName() == \"Dream-Enhancing Serum\" then isDES = true end\n\n maybeUpdateActiveInvestigator(object)\n syncCustomizableMetadata(object)\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n elseif shouldSpawnTokens(object) then\n spawnTokensFor(object)\n end\nend\n\n-- detect if \"Dream-Enhancing Serum\" is removed\nfunction onCollisionExit(collisionInfo)\n if collisionInfo.collision_object.getName() == \"Dream-Enhancing Serum\" then isDES = false end\nend\n\n-- checks if tokens should be spawned for the provided card\nfunction shouldSpawnTokens(card)\n if card.is_face_down then\n return false\n end\n\n local localCardPos = self.positionToLocal(card.getPosition())\n local metadata = JSON.decode(card.getGMNotes())\n\n -- If no metadata we don't know the type, so only spawn in the main area\n if metadata == nil then\n return inArea(localCardPos, MAIN_PLAY_AREA)\n end\n\n -- Spawn tokens for assets and events on the main area\n if inArea(localCardPos, MAIN_PLAY_AREA)\n and (metadata.type == \"Asset\"\n or metadata.type == \"Event\") then\n return true\n end\n\n -- Spawn tokens for all encounter types in the threat area\n if inArea(localCardPos, THREAT_AREA)\n and (metadata.type == \"Treachery\"\n or metadata.type == \"Enemy\"\n or metadata.weakness) then\n return true\n end\n\n return false\nend\n\nfunction onObjectEnterContainer(container, object)\n if object.type ~= \"Card\" then return end\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n end\nend\n\n-- removes tokens from the provided card/deck\nfunction removeTokensFromObject(object)\n if object.hasTag(\"CardThatSeals\") then\n local func = object.getVar(\"resetSealedTokens\") -- check if function exists (it won't for older custom content)\n if func ~= nil then\n object.call(\"resetSealedTokens\")\n end\n end\n\n for _, obj in ipairs(searchLib.onObject(object)) do\n if tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n elseif obj.getGUID() ~= \"4ee1f2\" and -- table\n obj ~= self and\n obj.type ~= \"Deck\" and\n obj.type ~= \"Card\" and\n obj.memo ~= nil and\n obj.getLock() == false and\n obj.getDescription() ~= \"Action Token\" then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n---------------------------------------------------------\n-- investigator ID grabbing and skill tracker\n---------------------------------------------------------\n\nfunction maybeUpdateActiveInvestigator(card)\n if not inArea(self.positionToLocal(card.getPosition()), INVESTIGATOR_AREA) then return end\n\n local notes = JSON.decode(card.getGMNotes())\n local class\n\n if notes ~= nil and notes.type == \"Investigator\" and notes.id ~= nil then\n if notes.id == activeInvestigatorId then return end\n class = notes.class\n activeInvestigatorId = notes.id\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", {\n notes.willpowerIcons,\n notes.intellectIcons,\n notes.combatIcons,\n notes.agilityIcons\n })\n elseif activeInvestigatorId ~= \"00000\" then\n class = \"Neutral\"\n activeInvestigatorId = \"00000\"\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", {1, 1, 1, 1})\n else\n return\n end\n\n -- change state of action tokens\n local search = searchArea(self.positionToWorld({-1.1, 0.05, -0.27}), {4, 1, 1})\n local smallToken = nil\n local STATE_TABLE = {\n [\"Guardian\"] = 1,\n [\"Seeker\"] = 2,\n [\"Rogue\"] = 3,\n [\"Mystic\"] = 4,\n [\"Survivor\"] = 5,\n [\"Neutral\"] = 6\n }\n\n for _, obj in ipairs(search) do\n if obj.getDescription() == \"Action Token\" and obj.getStateId() \u003e 0 then\n if obj.getScale().x \u003c 0.4 then\n smallToken = obj\n else\n setObjectState(obj, STATE_TABLE[class])\n end\n end\n end\n\n -- update the small token with special action for certain investigators\n local SPECIAL_ACTIONS = {\n [\"04002\"] = 8, -- Ursula Downs\n [\"01002\"] = 9, -- Daisy Walker\n [\"01502\"] = 9, -- Daisy Walker\n [\"01002-pb\"] = 9, -- Daisy Walker\n [\"06003\"] = 10, -- Tony Morgan\n [\"04003\"] = 11, -- Finn Edwards\n [\"08016\"] = 14 -- Bob Jenkins\n }\n\n if smallToken ~= nil then\n setObjectState(smallToken, SPECIAL_ACTIONS[activeInvestigatorId] or STATE_TABLE[class])\n end\nend\n\nfunction setObjectState(obj, stateId)\n if obj.getStateId() ~= stateId then obj.setState(stateId) end\nend\n\n---------------------------------------------------------\n-- manipulation of owned objects\n---------------------------------------------------------\n\n-- updates the specific owned counter\n---@param param table Contains the information to update:\n--- type: String Counter to target\n--- newValue: Number Value to set the counter to\n--- modifier: Number If newValue is not provided, the existing value will be adjusted by this modifier\nfunction updateCounter(param)\n local counter = ownedObjects[param.type]\n if counter ~= nil then\n counter.call(\"updateVal\", param.newValue or (counter.getVar(\"val\") + param.modifier))\n else\n printToAll(param.type .. \" for \" .. matColor .. \" could not be found.\", \"Yellow\")\n end\nend\n\n-- returns the resource counter amount\n---@param type string Counter to target\nfunction getCounterValue(type)\n return ownedObjects[type].getVar(\"val\")\nend\n\n-- set investigator skill tracker to \"1, 1, 1, 1\"\nfunction resetSkillTracker()\n local obj = ownedObjects.InvestigatorSkillTracker\n if obj ~= nil then\n obj.call(\"updateStats\", { 1, 1, 1, 1 })\n else\n printToAll(\"Skill tracker for \" .. matColor .. \" playmat could not be found.\", \"Yellow\")\n end\nend\n\n---------------------------------------------------------\n-- calls to 'Global' / functions for calls from outside\n---------------------------------------------------------\n\nfunction drawChaosTokenButton(_, _, isRightClick)\n chaosBagApi.drawChaosToken(self, isRightClick)\nend\n\nfunction drawEncounterCard(_, _, isRightClick)\n mythosAreaApi.drawEncounterCard(self, isRightClick)\nend\n\nfunction returnGlobalDiscardPosition()\n return self.positionToWorld(DISCARD_PILE_POSITION)\nend\n\n-- Sets this playermat's draw 1 button to visible\n---@param visible boolean Whether the draw 1 button should be visible\nfunction showDrawButton(visible)\n isDrawButtonVisible = visible\n\n -- create the \"Draw 1\" button\n if isDrawButtonVisible then\n self.createButton({\n label = \"Draw 1\",\n click_function = \"doDrawOne\",\n function_owner = self,\n position = { 1.84, 0.1, -0.36 },\n scale = { 0.12, 0.12, 0.12 },\n width = 800,\n height = 280,\n font_size = 180\n })\n\n -- remove the \"Draw 1\" button\n else\n local buttons = self.getButtons()\n for i = 1, #buttons do\n if buttons[i].label == \"Draw 1\" then\n self.removeButton(buttons[i].index)\n end\n end\n end\nend\n\n-- shows / hides a clickable clue counter for this playmat and sets the correct amount of clues\n---@param showCounter boolean Whether the clickable clue counter should be visible\nfunction clickableClues(showCounter)\n local clickerPos = ownedObjects.ClickableClueCounter.getPosition()\n local clueCount = 0\n \n -- move clue counters\n local modY = showCounter and 0.525 or -0.525\n ownedObjects.ClickableClueCounter.setPosition(clickerPos + Vector(0, modY, 0))\n\n if showCounter then\n -- current clue count\n clueCount = ownedObjects.ClueCounter.getVar(\"exposedValue\")\n\n -- remove clues\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n\n -- set value for clue clickers\n ownedObjects.ClickableClueCounter.call(\"updateVal\", clueCount)\n else\n -- current clue count\n clueCount = ownedObjects.ClickableClueCounter.getVar(\"val\")\n\n -- spawn clues\n local pos = self.positionToWorld({x = -1.12, y = 0.05, z = 0.7})\n for i = 1, clueCount do\n pos.y = pos.y + 0.045 * i\n tokenManager.spawnToken(pos, \"clue\", self.getRotation())\n end\n end\nend\n\n-- removes all clues (moving tokens to the trash and setting counters to 0)\nfunction removeClues()\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n ownedObjects.ClickableClueCounter.call(\"updateVal\", 0)\nend\n\n-- reports the clue count\n---@param useClickableCounters boolean Controls which type of counter is getting checked\nfunction getClueCount(useClickableCounters)\n if useClickableCounters then\n return ownedObjects.ClickableClueCounter.getVar(\"val\")\n else\n return ownedObjects.ClueCounter.getVar(\"exposedValue\")\n end\nend\n\n-- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes\n-- is true, the main card slot snap points will only snap assets, while the investigator area point\n-- will only snap Investigators. If matchTypes is false, snap points will be reset to snap all cards.\n---@param matchTypes boolean Whether snap points should only snap for the matching card types.\nfunction setLimitSnapsByType(matchTypes)\n local snaps = self.getSnapPoints()\n for i, snap in ipairs(snaps) do\n local snapPos = snap.position\n if inArea(snapPos, MAIN_PLAY_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Asset\" }\n else\n table.insert(snaps[i].tags, \"Asset\")\n end\n else\n snaps[i].tags = nil\n end\n end\n if inArea(snapPos, INVESTIGATOR_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Investigator\" }\n else\n table.insert(snaps[i].tags, \"Investigator\")\n end\n else\n snaps[i].tags = nil\n end\n end\n end\n self.setSnapPoints(snaps)\nend\n\n-- Simple method to check if the given point is in a specified area. Local use only,\n---@param point tts__Vector Point to check, only x and z values are relevant\n---@param bounds table Defined area to see if the point is within. See MAIN_PLAY_AREA for sample\n-- bounds definition.\n---@return boolean: True if the point is in the area defined by bounds\nfunction inArea(point, bounds)\n return (point.x \u003c bounds.upperLeft.x\n and point.x \u003e bounds.lowerRight.x\n and point.z \u003c bounds.upperLeft.z\n and point.z \u003e bounds.lowerRight.z)\nend\n\n-- called by custom data helpers to add player card data\n---@param args table Contains only one entry, the GUID of the custom data helper\nfunction updatePlayerCards(args)\n local customDataHelper = getObjectFromGUID(args[1])\n local playerCardData = customDataHelper.getTable(\"PLAYER_CARD_DATA\")\n tokenManager.addPlayerCardData(playerCardData)\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot table New rotation for the object (optional)\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local newPos\n local offset = 0.5\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n else\n newPos = Vector(pos) + Vector(0, offset, 0)\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", - "LuaScriptState": "{\"activeInvestigatorId\":\"00000\",\"isDrawButtonVisible\":false,\"playerColor\":\"Orange\"}", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/Playmat\")\nend)\n__bundle_register(\"playermat/Playmat\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal deckLib = require(\"util/DeckLib\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal navigationOverlayApi = require(\"core/NavigationOverlayApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenChecker = require(\"core/token/TokenChecker\")\nlocal tokenManager = require(\"core/token/TokenManager\")\n\n-- we use this to turn off collision handling until onLoad() is complete\nlocal collisionEnabled = false\nlocal currentlyEditingSlots = false\n\n-- x-Values for discard buttons\nlocal DISCARD_BUTTON_X_START = -1.365\nlocal DISCARD_BUTTON_X_OFFSET = 0.455\n\nlocal SEARCH_AROUND_SELF_X_BUFFER = 8\n\n-- defined areas for object searching\nlocal MAIN_PLAY_AREA = {\n upperLeft = { x = 1.98, z = 0.736 },\n lowerRight = { x = -0.79, z = -0.39 }\n}\nlocal INVESTIGATOR_AREA = {\n upperLeft = { x = -1.084, z = 0.06517 },\n lowerRight = { x = -1.258, z = -0.0805 }\n}\nlocal THREAT_AREA = {\n upperLeft = { x = 1.53, z = -0.34 },\n lowerRight = { x = -1.13, z = -0.92 }\n}\nlocal DECK_DISCARD_AREA = {\n upperLeft = { x = -1.62, z = 0.855 },\n lowerRight = { x = -2.02, z = -0.245 },\n center = { x = -1.82, y = 0.5, z = 0.305 },\n size = { x = 0.4, y = 3, z = 1.1 }\n}\n\n-- local positions\nlocal DRAW_DECK_POSITION = { x = -1.82, y = 0.1, z = 0 }\nlocal DISCARD_PILE_POSITION = { x = -1.82, y = 0.1, z = 0.61 }\nlocal DRAWN_ENCOUNTER_POSITION = { x = 1.365, y = 0.5, z = -0.625 }\n\n-- global position of encounter discard pile\nlocal ENCOUNTER_DISCARD_POSITION = { x = -3.85, y = 1.5, z = 10.38 }\n\n-- used for the buttons on the right side of the playmat\n-- starts off with the data for the \"Upkeep\" button and will then be changed\nlocal buttonParameters = {\n label = \"Upkeep\",\n click_function = \"doUpkeep\",\n tooltip = \"Right-click to change color\",\n function_owner = self,\n position = { x = 1.82, y = 0.1, z = -0.45 },\n scale = { 0.12, 0.12, 0.12 },\n width = 1000,\n height = 280,\n font_size = 180\n}\n\n-- translation table for slot names to characters for special font\nlocal slotNameToChar = {\n [\"any\"] = \"\",\n [\"Accessory\"] = \"C\",\n [\"Ally\"] = \"E\",\n [\"Arcane\"] = \"G\",\n [\"Body\"] = \"K\",\n [\"Hand (right)\"] = \"M\",\n [\"Hand (left)\"] = \"M\",\n [\"Hand x2\"] = \"N\",\n [\"Tarot\"] = \"A\"\n}\n\n-- slot symbol for the respective slot (from top left to bottom right)\nlocal slotData = {}\nlocal defaultSlotData = {\n -- 1st row\n \"any\", \"any\", \"any\", \"Tarot\", \"Hand (left)\", \"Hand (right)\", \"Ally\",\n\n -- 2nd row\n \"any\", \"any\", \"any\", \"Accessory\", \"Arcane\", \"Arcane\", \"Body\"\n}\n\n-- global variable so it can be reset by the Clean Up Helper\nactiveInvestigatorId = \"00000\"\nlocal isDrawButtonVisible = false\n\n-- global variable to report \"Dream-Enhancing Serum\" status\nisDES = false\n\n-- table of type-object reference pairs of all owned objects\nlocal ownedObjects = {}\nlocal matColor = self.getMemo()\n\nfunction onSave()\n return JSON.encode({\n playerColor = playerColor,\n activeInvestigatorId = activeInvestigatorId,\n isDrawButtonVisible = isDrawButtonVisible,\n slotData = slotData\n })\nend\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n playerColor = loadedData.playerColor\n activeInvestigatorId = loadedData.activeInvestigatorId\n isDrawButtonVisible = loadedData.isDrawButtonVisible\n slotData = loadedData.slotData\n end\n\n self.interactable = false\n\n -- get object references to owned objects\n ownedObjects = guidReferenceApi.getObjectsByOwner(matColor)\n\n -- discard button creation\n for i = 1, 6 do\n makeDiscardButton(i)\n end\n\n self.createButton({\n click_function = \"drawEncounterCard\",\n function_owner = self,\n position = { -1.84, 0, -0.65 },\n rotation = { 0, 80, 0 },\n width = 265,\n height = 190\n })\n\n self.createButton({\n click_function = \"drawChaosTokenButton\",\n function_owner = self,\n position = { 1.85, 0, -0.74 },\n rotation = { 0, -45, 0 },\n width = 135,\n height = 135\n })\n\n -- Upkeep button: can use the default parameters for this\n self.createButton(buttonParameters)\n\n -- Slot editing button: modified default data\n buttonParameters.label = \"Edit Slots\"\n buttonParameters.click_function = \"toggleSlotEditing\"\n buttonParameters.tooltip = \"Right-click to reset slot symbols\"\n buttonParameters.position.z = 0.92\n self.createButton(buttonParameters)\n\n showDrawButton(isDrawButtonVisible)\n redrawSlotSymbols()\n math.randomseed(os.time())\n Wait.time(function() collisionEnabled = true end, 0.1)\nend\n\n---------------------------------------------------------\n-- utility functions\n---------------------------------------------------------\n\n-- searches an area and optionally filters the result\nfunction searchArea(origin, size, filter)\n return searchLib.inArea(origin, self.getRotation(), size, filter)\nend\n\n-- finds all objects on the playmat and associated set aside zone.\nfunction searchAroundSelf(filter)\n local bounds = self.getBoundsNormalized()\n -- Increase the width to cover the set aside zone\n bounds.size.x = bounds.size.x + SEARCH_AROUND_SELF_X_BUFFER\n bounds.size.y = 1\n -- Since the cast is centered on the position, shift left or right to keep the non-set aside edge\n -- of the cast at the edge of the playmat\n -- setAsideDirection accounts for the set aside zone being on the left or right, depending on the\n -- table position of the playmat\n local setAsideDirection = bounds.center.z \u003e 0 and 1 or -1\n local localCenter = self.positionToLocal(bounds.center)\n localCenter.x = localCenter.x + setAsideDirection * SEARCH_AROUND_SELF_X_BUFFER / 2 / self.getScale().x\n return searchArea(self.positionToWorld(localCenter), bounds.size, filter)\nend\n\n-- searches the area around the draw deck and discard pile\nfunction searchDeckAndDiscardArea(filter)\n local pos = self.positionToWorld(DECK_DISCARD_AREA.center)\n local scale = self.getScale()\n local size = {\n x = DECK_DISCARD_AREA.size.x * scale.x,\n y = DECK_DISCARD_AREA.size.y,\n z = DECK_DISCARD_AREA.size.z * scale.z\n }\n return searchArea(pos, size, filter)\nend\n\n-- rounds a number to the specified amount of decimal places\n---@param num number Initial value\n---@param numDecimalPlaces number Amount of decimal places\n---@return number: rounded number\nfunction round(num, numDecimalPlaces)\n local mult = 10 ^ (numDecimalPlaces or 0)\n return math.floor(num * mult + 0.5) / mult\nend\n\n-- edits the label of a button\n---@param oldLabel string Old label of the button\n---@param newLabel string New label of the button\nfunction editButtonLabel(oldLabel, newLabel)\n local buttons = self.getButtons()\n for i = 1, #buttons do\n if buttons[i].label == oldLabel then\n self.editButton({ index = buttons[i].index, label = newLabel })\n end\n end\nend\n\n-- updates the internal \"messageColor\" which is used for print/broadcast statements if no player is seated\n---@param clickedByColor string Colorstring of player who clicked a button\nfunction updateMessageColor(clickedByColor)\n messageColor = Player[playerColor].seated and playerColor or clickedByColor\nend\n\n---------------------------------------------------------\n-- Discard buttons\n---------------------------------------------------------\n\n-- handles discarding for a list of objects\n---@param objList table List of objects to discard\nfunction discardListOfObjects(objList)\n for _, obj in ipairs(objList) do\n if obj.type == \"Card\" or obj.type == \"Deck\" then\n if obj.hasTag(\"PlayerCard\") then\n deckLib.placeOrMergeIntoDeck(obj, returnGlobalDiscardPosition(), self.getRotation())\n else\n deckLib.placeOrMergeIntoDeck(obj, ENCOUNTER_DISCARD_POSITION, { x = 0, y = -90, z = 0 })\n end\n\n -- put chaos tokens back into bag (e.g. Unrelenting)\n elseif tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n\n -- don't touch locked objects (like the table etc.) or specific objects (like key tokens)\n elseif not obj.getLock() and not obj.hasTag(\"DontDiscard\") then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n-- build a discard button to discard from searchPosition\n---@param id number Index of the discard button (from left to right, must be unique)\nfunction makeDiscardButton(id)\n local xValue = DISCARD_BUTTON_X_START + (id - 1) * DISCARD_BUTTON_X_OFFSET\n local position = { xValue, 0.1, -0.94 }\n local searchPosition = { -position[1], position[2], position[3] + 0.32 }\n local handlerName = 'handler' .. id\n self.setVar(handlerName, function()\n local cardSizeSearch = { 2, 1, 3.2 }\n local globalSearchPosition = self.positionToWorld(searchPosition)\n local searchResult = searchArea(globalSearchPosition, cardSizeSearch)\n return discardListOfObjects(searchResult)\n end)\n self.createButton({\n label = \"Discard\",\n click_function = handlerName,\n function_owner = self,\n position = position,\n scale = { 0.12, 0.12, 0.12 },\n width = 900,\n height = 350,\n font_size = 220\n })\nend\n\n---------------------------------------------------------\n-- Upkeep button\n---------------------------------------------------------\n\n-- calls the Upkeep function with correct parameter\nfunction doUpkeepFromHotkey(clickedByColor)\n doUpkeep(_, clickedByColor)\nend\n\nfunction doUpkeep(_, clickedByColor, isRightClick)\n if isRightClick then\n changeColor(clickedByColor)\n return\n end\n\n updateMessageColor(clickedByColor)\n\n -- unexhaust cards in play zone, flip action tokens and find forcedLearning\n local forcedLearning = false\n local rot = self.getRotation()\n for _, obj in ipairs(searchAroundSelf()) do\n if obj.getDescription() == \"Action Token\" and obj.is_face_down then\n obj.flip()\n elseif obj.type == \"Card\" and not inArea(self.positionToLocal(obj.getPosition()), INVESTIGATOR_AREA) then\n local cardMetadata = JSON.decode(obj.getGMNotes()) or {}\n if not (obj.getVar(\"do_not_ready\") or false) then\n local cardRotation = round(obj.getRotation().y, 0) - rot.y\n local yRotDiff = 0\n\n if cardRotation \u003c 0 then\n cardRotation = cardRotation + 360\n end\n\n -- rotate cards to the next multiple of 90° towards 0°\n if cardRotation \u003e 90 and cardRotation \u003c= 180 then\n yRotDiff = 90\n elseif cardRotation \u003c 270 and cardRotation \u003e 180 then\n yRotDiff = 270\n end\n\n -- set correct rotation for face-down cards\n rot.z = obj.is_face_down and 180 or 0\n obj.setRotation({ rot.x, rot.y + yRotDiff, rot.z })\n end\n\n -- detect forced learning to handle card drawing accordingly\n if cardMetadata.id == \"08031\" then\n forcedLearning = true\n end\n\n -- maybe replenish uses on certain cards\n if cardMetadata.uses ~= nil then\n tokenManager.maybeReplenishCard(obj, cardMetadata.uses, self)\n end\n elseif obj.type == \"Deck\" and forcedLearning == false then\n -- check decks for forced learning\n for _, deepObj in ipairs(obj.getObjects()) do\n local cardMetadata = JSON.decode(deepObj.gm_notes) or {}\n if cardMetadata.id == \"08031\" then\n forcedLearning = true\n end\n end\n end\n end\n\n -- flip investigator mini-card and summoned servitor mini-card\n -- (all characters allowed to account for custom IDs - e.g. 'Z0000' for TTS Zoop generated IDs)\n local miniId = string.match(activeInvestigatorId, \".....\") .. \"-m\"\n for _, obj in ipairs(getObjects()) do\n if obj.type == \"Card\" and obj.is_face_down then\n local notes = JSON.decode(obj.getGMNotes())\n if notes ~= nil and notes.type == \"Minicard\" and (notes.id == miniId or notes.id == \"09080-m\") then\n obj.flip()\n end\n end\n end\n\n -- gain a resource (or two if playing Jenny Barnes)\n if string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"02003\" then\n updateCounter({ type = \"ResourceCounter\", modifier = 2 })\n printToColor(\"Gaining 2 resources (Jenny)\", messageColor)\n else\n updateCounter({ type = \"ResourceCounter\", modifier = 1 })\n end\n\n -- draw a card (with handling for Patrice and Forced Learning)\n if activeInvestigatorId == \"06005\" then\n if forcedLearning then\n printToColor(\"Wow, did you really take 'Versatile' to play Patrice with 'Forced Learning'?\"\n .. \" Choose which draw replacement effect takes priority and draw cards accordingly.\", messageColor)\n else\n local handSize = #Player[playerColor].getHandObjects()\n if handSize \u003c 5 then\n local cardsToDraw = 5 - handSize\n printToColor(\"Drawing \" .. cardsToDraw .. \" cards (Patrice)\", messageColor)\n drawCardsWithReshuffle(cardsToDraw)\n end\n end\n elseif forcedLearning then\n printToColor(\"Drawing 2 cards, discard 1 (Forced Learning)\", messageColor)\n drawCardsWithReshuffle(2)\n elseif activeInvestigatorId == \"89001\" then\n printToColor(\"Drawing 2 cards (Subject 5U-21)\", messageColor)\n drawCardsWithReshuffle(2)\n else\n drawCardsWithReshuffle(1)\n end\nend\n\n-- click function for \"draw 1 button\" (that can be added via option panel)\nfunction doDrawOne(_, clickedByColor)\n updateMessageColor(clickedByColor)\n drawCardsWithReshuffle(1)\nend\n\n-- draws the specified amount of cards (and shuffles the discard if necessary)\n---@param numCards number Number of cards to draw\nfunction drawCardsWithReshuffle(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n\n -- Norman Withers handling\n local harbinger = false\n if deckAreaObjects.topCard and deckAreaObjects.topCard.getName() == \"The Harbinger\" then\n harbinger = true\n elseif deckAreaObjects.draw and not deckAreaObjects.draw.is_face_down then\n local cards = deckAreaObjects.draw.getObjects()\n if cards[#cards].name == \"The Harbinger\" then\n harbinger = true\n end\n end\n\n if harbinger then\n printToColor(\"The Harbinger is on top of your deck, not drawing cards\", messageColor)\n return\n end\n\n local topCardDetected = false\n if deckAreaObjects.topCard ~= nil then\n deckAreaObjects.topCard.deal(1, playerColor)\n topCardDetected = true\n numCards = numCards - 1\n if numCards == 0 then\n flipTopCardFromDeck()\n return\n end\n end\n\n local deckSize = 1\n if deckAreaObjects.draw == nil then\n deckSize = 0\n elseif deckAreaObjects.draw.type == \"Deck\" then\n deckSize = #deckAreaObjects.draw.getObjects()\n end\n\n if deckSize \u003e= numCards then\n drawCards(numCards)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n else\n drawCards(deckSize)\n if deckAreaObjects.discard ~= nil then\n shuffleDiscardIntoDeck()\n Wait.time(function()\n drawCards(numCards - deckSize)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n end, 1)\n end\n printToColor(\"Take 1 horror (drawing card from empty deck)\", messageColor)\n end\nend\n\n-- get the draw deck and discard pile objects and returns the references\n---@return table: string-indexed table with references to the found objects\nfunction getDeckAreaObjects()\n local deckAreaObjects = {}\n for _, object in ipairs(searchDeckAndDiscardArea(\"isCardOrDeck\")) do\n if self.positionToLocal(object.getPosition()).z \u003e 0.5 then\n deckAreaObjects.discard = object\n -- Norman Withers handling\n elseif object.type == \"Card\" and not object.is_face_down then\n deckAreaObjects.topCard = object\n else\n deckAreaObjects.draw = object\n end\n end\n return deckAreaObjects\nend\n\n-- draws the specified number of cards (reshuffling of discard pile is handled separately)\n---@param numCards number Number of cards to draw\nfunction drawCards(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.draw then\n deckAreaObjects.draw.deal(numCards, playerColor)\n end\nend\n\nfunction shuffleDiscardIntoDeck()\n local deckAreaObjects = getDeckAreaObjects()\n if not deckAreaObjects.discard.is_face_down then\n deckAreaObjects.discard.flip()\n end\n deckAreaObjects.discard.shuffle()\n deckAreaObjects.discard.setPositionSmooth(self.positionToWorld(DRAW_DECK_POSITION), false, false)\nend\n\n-- utility function for Norman Withers to flip the top card to the revealed side\nfunction flipTopCardFromDeck()\n Wait.time(function()\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.topCard then\n elseif deckAreaObjects.draw then\n if deckAreaObjects.draw.type == \"Card\" then\n deckAreaObjects.draw.flip()\n else\n -- get bounds to know the height of the deck\n local bounds = deckAreaObjects.draw.getBounds()\n local pos = bounds.center + Vector(0, bounds.size.y / 2 + 0.2, 0)\n deckAreaObjects.draw.takeObject({ position = pos, flip = true })\n end\n end\n end, 0.1)\nend\n\n-- discard a random non-hidden card from hand\nfunction doDiscardOne()\n local hand = Player[playerColor].getHandObjects()\n if #hand == 0 then\n broadcastToColor(\"Cannot discard from empty hand!\", messageColor, \"Red\")\n else\n local choices = {}\n for i = 1, #hand do\n local notes = JSON.decode(hand[i].getGMNotes())\n if notes ~= nil then\n if notes.hidden ~= true then\n table.insert(choices, i)\n end\n else\n table.insert(choices, i)\n end\n end\n\n if #choices == 0 then\n broadcastToColor(\"Hidden cards can't be randomly discarded.\", messageColor, \"Orange\")\n return\n end\n\n -- get a random non-hidden card (from the \"choices\" table)\n local num = math.random(1, #choices)\n deckLib.placeOrMergeIntoDeck(hand[choices[num]], returnGlobalDiscardPosition(), self.getRotation())\n\n local playerName = Player[playerColor].steam_name or playerColor\n broadcastToAll(playerName .. \" randomly discarded card \" .. choices[num] .. \"/\" .. #hand .. \".\", \"White\")\n end\nend\n\n---------------------------------------------------------\n-- slot symbol displaying\n---------------------------------------------------------\n\n-- this will redraw the XML for the slot symbols based on the slotData table\nfunction redrawSlotSymbols()\n local xml = {}\n local snapId = 0\n\n -- use the snap point positions in the main play area for positions\n for _, snap in ipairs(self.getSnapPoints()) do\n if inArea(snap.position, MAIN_PLAY_AREA) then\n snapId = snapId + 1\n local slotName = slotData[snapId]\n\n -- conversion from regular coordinates to XML\n local x = snap.position.x * 100\n local y = snap.position.z * 100\n\n -- XML for a single slot (panel with text in the special font)\n local slotXML = {\n tag = \"Panel\",\n attributes = {\n id = \"slotPanel\" .. snapId,\n scale = \"0.1 0.1 1\",\n width = \"175\",\n height = \"175\",\n position = x .. \" \" .. y .. \" -11\"\n },\n children = {\n {\n tag = \"Text\",\n attributes = {\n id = \"slot\" .. snapId,\n rotation = getSlotRotation(slotName),\n fontSize = \"145\",\n font = \"font_arkhamicons\",\n color = \"#414141CB\",\n text = slotNameToChar[slotName]\n }\n }\n }\n }\n table.insert(xml, slotXML)\n end\n end\n\n self.UI.setXmlTable(xml)\nend\n\n-- toggle the \"slot editing mode\"\nfunction toggleSlotEditing(_, clickedByColor, isRightClick)\n if isRightClick then\n resetSlotSymbols()\n return\n end\n\n updateMessageColor(clickedByColor)\n\n -- toggle internal variable\n currentlyEditingSlots = not currentlyEditingSlots\n\n if currentlyEditingSlots then\n editButtonLabel(\"Edit Slots\", \"Stop editing\")\n broadcastToColor(\"Click on a slot symbol (or an empty slot) to edit it.\", messageColor, \"Orange\")\n addClickFunctionToSlots()\n else\n editButtonLabel(\"Stop editing\", \"Edit Slots\")\n redrawSlotSymbols()\n end\nend\n\n-- click function for slot symbols during the \"slot editing mode\"\nfunction slotClickfunction(player, _, id)\n local slotIndex = id:gsub(\"slotPanel\", \"\")\n slotIndex = tonumber(slotIndex)\n\n -- make a list of the table keys as options for the dialog box\n local slotNames = {}\n for slotName, _ in pairs(slotNameToChar) do\n table.insert(slotNames, slotName)\n end\n\n -- prompt player to choose symbol\n player.showOptionsDialog(\"Choose Slot Symbol\", slotNames, slotData[slotIndex],\n function(chosenSlotName)\n slotData[slotIndex] = chosenSlotName\n\n -- update slot symbol\n self.UI.setAttribute(\"slot\" .. slotIndex, \"text\", slotNameToChar[chosenSlotName])\n\n -- update slot rotation\n self.UI.setAttribute(\"slot\" .. slotIndex, \"rotation\", getSlotRotation(chosenSlotName))\n end\n )\nend\n\n-- helper function to rotate the left hand\nfunction getSlotRotation(slotName)\n if slotName == \"Hand (left)\" then\n return \"0 180 180\"\n else\n return \"0 0 180\"\n end\nend\n\n-- reset the slot symbols by making a deep copy of the default data and redrawing\nfunction resetSlotSymbols()\n slotData = {}\n for _, slotName in ipairs(defaultSlotData) do\n table.insert(slotData, slotName)\n end\n\n redrawSlotSymbols()\n\n -- need to re-add the click functions if currently in edit mode\n if currentlyEditingSlots then\n addClickFunctionToSlots()\n end\nend\n\n-- enables the click functions for editing\nfunction addClickFunctionToSlots()\n for i = 1, #slotData do\n self.UI.setAttribute(\"slotPanel\" .. i, \"onClick\", \"slotClickfunction\")\n end\nend\n\n---------------------------------------------------------\n-- color related functions\n---------------------------------------------------------\n\n-- changes the player color\nfunction changeColor(clickedByColor)\n local colorList = Player.getColors()\n\n -- remove existing colors from the list of choices\n for _, existingColor in ipairs(Player.getAvailableColors()) do\n for i, newColor in ipairs(colorList) do\n if existingColor == newColor or newColor == \"Black\" or newColor == \"Grey\" then\n table.remove(colorList, i)\n end\n end\n end\n\n -- show the option dialog for color selection to the player that triggered this\n Player[clickedByColor].showOptionsDialog(\"Select a new color:\", colorList, _, function(color)\n -- update the color of the hand zone\n local handZone = ownedObjects.HandZone\n handZone.setValue(color)\n\n -- if the seated player clicked this, reseat him to the new color\n if clickedByColor == playerColor then\n navigationOverlayApi.copyVisibility(playerColor, color)\n Player[playerColor].changeColor(color)\n end\n\n -- update the internal variable\n playerColor = color\n end)\nend\n\n---------------------------------------------------------\n-- playmat token spawning\n---------------------------------------------------------\n\n-- Finds all customizable cards in this play area and updates their metadata based on the selections\n-- on the matching upgrade sheet.\n-- This method is theoretically O(n^2), and should be used sparingly. In practice it will only be\n-- called when a checkbox is added or removed in-game (which should be rare), and is bounded by the\n-- number of customizable cards in play.\nfunction syncAllCustomizableCards()\n for _, card in ipairs(searchAroundSelf(\"isCard\")) do\n syncCustomizableMetadata(card)\n end\nend\n\nfunction syncCustomizableMetadata(card)\n local cardMetadata = JSON.decode(card.getGMNotes()) or {}\n if cardMetadata == nil or cardMetadata.customizations == nil then return end\n\n for _, upgradeSheet in ipairs(searchAroundSelf(\"isCard\")) do\n local upgradeSheetMetadata = JSON.decode(upgradeSheet.getGMNotes()) or {}\n if upgradeSheetMetadata.id == (cardMetadata.id .. \"-c\") then\n for i, customization in ipairs(cardMetadata.customizations) do\n if customization.replaces ~= nil and customization.replaces.uses ~= nil then\n if upgradeSheet.call(\"isUpgradeActive\", i) then\n cardMetadata.uses = customization.replaces.uses\n card.setGMNotes(JSON.encode(cardMetadata))\n else\n -- TODO: Get the original metadata to restore it... maybe. This should only be\n -- necessary in the very unlikely case that a user un-checks a previously-full upgrade\n -- row while the card is in play. It will be much easier once the AllPlayerCardsApi is\n -- in place, so defer until it is\n end\n end\n end\n end\n end\nend\n\nfunction spawnTokensFor(object)\n local extraUses = {}\n if activeInvestigatorId == \"03004\" then\n extraUses[\"Charge\"] = 1\n end\n\n tokenManager.spawnForCard(object, extraUses)\nend\n\nfunction onCollisionEnter(collisionInfo)\n local object = collisionInfo.collision_object\n\n -- only continue if loading is completed\n if not collisionEnabled then return end\n\n -- only continue for cards\n if object.type ~= \"Card\" then return end\n\n -- detect if \"Dream-Enhancing Serum\" is placed\n if object.getName() == \"Dream-Enhancing Serum\" then isDES = true end\n\n maybeUpdateActiveInvestigator(object)\n syncCustomizableMetadata(object)\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n elseif shouldSpawnTokens(object) then\n spawnTokensFor(object)\n end\nend\n\n-- detect if \"Dream-Enhancing Serum\" is removed\nfunction onCollisionExit(collisionInfo)\n if collisionInfo.collision_object.getName() == \"Dream-Enhancing Serum\" then isDES = false end\nend\n\n-- checks if tokens should be spawned for the provided card\nfunction shouldSpawnTokens(card)\n if card.is_face_down then\n return false\n end\n\n local localCardPos = self.positionToLocal(card.getPosition())\n local metadata = JSON.decode(card.getGMNotes())\n\n -- If no metadata we don't know the type, so only spawn in the main area\n if metadata == nil then\n return inArea(localCardPos, MAIN_PLAY_AREA)\n end\n\n -- Spawn tokens for assets and events on the main area\n if inArea(localCardPos, MAIN_PLAY_AREA)\n and (metadata.type == \"Asset\"\n or metadata.type == \"Event\") then\n return true\n end\n\n -- Spawn tokens for all encounter types in the threat area\n if inArea(localCardPos, THREAT_AREA)\n and (metadata.type == \"Treachery\"\n or metadata.type == \"Enemy\"\n or metadata.weakness) then\n return true\n end\n\n return false\nend\n\nfunction onObjectEnterContainer(container, object)\n if object.type ~= \"Card\" then return end\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n end\nend\n\n-- removes tokens from the provided card/deck\nfunction removeTokensFromObject(object)\n if object.hasTag(\"CardThatSeals\") then\n local func = object.getVar(\"resetSealedTokens\") -- check if function exists (it won't for older custom content)\n if func ~= nil then\n object.call(\"resetSealedTokens\")\n end\n end\n\n for _, obj in ipairs(searchLib.onObject(object)) do\n if tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n elseif obj.getGUID() ~= \"4ee1f2\" and -- table\n obj ~= self and\n obj.type ~= \"Deck\" and\n obj.type ~= \"Card\" and\n obj.memo ~= nil and\n obj.getLock() == false and\n obj.getDescription() ~= \"Action Token\" then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n---------------------------------------------------------\n-- investigator ID grabbing and skill tracker\n---------------------------------------------------------\n\n-- updates the internal investigator id and action tokens if an investigator card is detected\n---@param card tts__Object Card that might be an investigator\nfunction maybeUpdateActiveInvestigator(card)\n if not inArea(self.positionToLocal(card.getPosition()), INVESTIGATOR_AREA) then return end\n\n local notes = JSON.decode(card.getGMNotes())\n local class\n\n if notes ~= nil and notes.type == \"Investigator\" and notes.id ~= nil then\n if notes.id == activeInvestigatorId then return end\n class = notes.class\n activeInvestigatorId = notes.id\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", {\n notes.willpowerIcons,\n notes.intellectIcons,\n notes.combatIcons,\n notes.agilityIcons\n })\n elseif activeInvestigatorId ~= \"00000\" then\n class = \"Neutral\"\n activeInvestigatorId = \"00000\"\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", { 1, 1, 1, 1 })\n else\n return\n end\n\n -- change state of action tokens\n local search = searchArea(self.positionToWorld({ -1.1, 0.05, -0.27 }), { 4, 1, 1 })\n local smallToken = nil\n local STATE_TABLE = {\n [\"Guardian\"] = 1,\n [\"Seeker\"] = 2,\n [\"Rogue\"] = 3,\n [\"Mystic\"] = 4,\n [\"Survivor\"] = 5,\n [\"Neutral\"] = 6\n }\n\n for _, obj in ipairs(search) do\n if obj.getDescription() == \"Action Token\" and obj.getStateId() \u003e 0 then\n if obj.getScale().x \u003c 0.4 then\n smallToken = obj\n else\n setObjectState(obj, STATE_TABLE[class])\n end\n end\n end\n\n -- update the small token with special action for certain investigators\n local SPECIAL_ACTIONS = {\n [\"04002\"] = 8, -- Ursula Downs\n [\"01002\"] = 9, -- Daisy Walker\n [\"01502\"] = 9, -- Daisy Walker\n [\"01002-pb\"] = 9, -- Daisy Walker\n [\"06003\"] = 10, -- Tony Morgan\n [\"04003\"] = 11, -- Finn Edwards\n [\"08016\"] = 14 -- Bob Jenkins\n }\n\n if smallToken ~= nil then\n setObjectState(smallToken, SPECIAL_ACTIONS[activeInvestigatorId] or STATE_TABLE[class])\n end\nend\n\nfunction setObjectState(obj, stateId)\n if obj.getStateId() ~= stateId then obj.setState(stateId) end\nend\n\n---------------------------------------------------------\n-- manipulation of owned objects\n---------------------------------------------------------\n\n-- updates the specified owned counter\n---@param param table Contains the information to update:\n--- type: String Counter to target\n--- newValue: Number Value to set the counter to\n--- modifier: Number If newValue is not provided, the existing value will be adjusted by this modifier\nfunction updateCounter(param)\n local counter = ownedObjects[param.type]\n if counter ~= nil then\n counter.call(\"updateVal\", param.newValue or (counter.getVar(\"val\") + param.modifier))\n else\n printToAll(param.type .. \" for \" .. matColor .. \" could not be found.\", \"Yellow\")\n end\nend\n\n-- get the value the specified owned counter\n---@param type string Counter to target\n---@return number: Counter value\nfunction getCounterValue(type)\n return ownedObjects[type].getVar(\"val\")\nend\n\n-- set investigator skill tracker to \"1, 1, 1, 1\"\nfunction resetSkillTracker()\n local obj = ownedObjects.InvestigatorSkillTracker\n if obj ~= nil then\n obj.call(\"updateStats\", { 1, 1, 1, 1 })\n else\n printToAll(\"Skill tracker for \" .. matColor .. \" playmat could not be found.\", \"Yellow\")\n end\nend\n\n---------------------------------------------------------\n-- calls to 'Global' / functions for calls from outside\n---------------------------------------------------------\n\nfunction drawChaosTokenButton(_, _, isRightClick)\n chaosBagApi.drawChaosToken(self, isRightClick)\nend\n\nfunction drawEncounterCard(_, _, isRightClick)\n local drawPos = getEncounterCardDrawPosition(not isRightClick)\n mythosAreaApi.drawEncounterCard(matColor, drawPos)\nend\n\nfunction returnGlobalDiscardPosition()\n return self.positionToWorld(DISCARD_PILE_POSITION)\nend\n\nfunction returnGlobalDrawPosition()\n return self.positionToWorld(DRAW_DECK_POSITION)\nend\n\n-- returns the position for encounter card drawing\n---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\nfunction getEncounterCardDrawPosition(stack)\n local drawPos = self.positionToWorld(DRAWN_ENCOUNTER_POSITION)\n\n -- maybe override position with first empty slot in threat area (right to left)\n if not stack then\n local searchPos = Vector(-0.91, 0.5, -0.625)\n for i = 1, 5 do\n local globalSearchPos = self.positionToWorld(searchPos)\n local searchResult = searchLib.atPosition(globalSearchPos, \"isCardOrDeck\")\n if #searchResult == 0 then\n drawPos = globalSearchPos\n break\n else\n searchPos.x = searchPos.x + 0.455\n end\n end\n end\n\n return drawPos\nend\n\n-- creates / removes the draw 1 button\n---@param visible boolean Whether the draw 1 button should be visible\nfunction showDrawButton(visible)\n isDrawButtonVisible = visible\n\n if isDrawButtonVisible then\n -- Draw 1 button: modified default data\n buttonParameters.label = \"Draw 1\"\n buttonParameters.click_function = \"doDrawOne\"\n buttonParameters.tooltip = \"\"\n buttonParameters.position.z = -0.35\n self.createButton(buttonParameters)\n else\n local buttons = self.getButtons()\n for i = 1, #buttons do\n if buttons[i].label == \"Draw 1\" then\n self.removeButton(buttons[i].index)\n end\n end\n end\nend\n\n-- shows / hides a clickable clue counter for this playmat and sets the correct amount of clues\n---@param showCounter boolean Whether the clickable clue counter should be visible\nfunction clickableClues(showCounter)\n local clickerPos = ownedObjects.ClickableClueCounter.getPosition()\n local clueCount = 0\n\n -- move clue counters\n local modY = showCounter and 0.525 or -0.525\n ownedObjects.ClickableClueCounter.setPosition(clickerPos + Vector(0, modY, 0))\n\n if showCounter then\n -- get current clue count\n clueCount = ownedObjects.ClueCounter.getVar(\"exposedValue\")\n\n -- remove clues\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n\n -- set value for clue clickers\n ownedObjects.ClickableClueCounter.call(\"updateVal\", clueCount)\n else\n -- get current clue count\n clueCount = ownedObjects.ClickableClueCounter.getVar(\"val\")\n\n -- spawn clues\n local pos = self.positionToWorld({ x = -1.12, y = 0.05, z = 0.7 })\n for i = 1, clueCount do\n pos.y = pos.y + 0.045 * i\n tokenManager.spawnToken(pos, \"clue\", self.getRotation())\n end\n end\nend\n\n-- removes all clues (moving tokens to the trash and setting counters to 0)\nfunction removeClues()\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n ownedObjects.ClickableClueCounter.call(\"updateVal\", 0)\nend\n\n-- reports the clue count\n---@param useClickableCounters boolean Controls which type of counter is getting checked\nfunction getClueCount(useClickableCounters)\n if useClickableCounters then\n return ownedObjects.ClickableClueCounter.getVar(\"val\")\n else\n return ownedObjects.ClueCounter.getVar(\"exposedValue\")\n end\nend\n\n-- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes\n-- is true, the main card slot snap points will only snap assets, while the investigator area point\n-- will only snap Investigators. If matchTypes is false, snap points will be reset to snap all cards.\n---@param matchTypes boolean Whether snap points should only snap for the matching card types.\nfunction setLimitSnapsByType(matchTypes)\n local snaps = self.getSnapPoints()\n for i, snap in ipairs(snaps) do\n if inArea(snap.position, MAIN_PLAY_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Asset\" }\n else\n table.insert(snaps[i].tags, \"Asset\")\n end\n else\n snaps[i].tags = nil\n end\n end\n if inArea(snap.position, INVESTIGATOR_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Investigator\" }\n else\n table.insert(snaps[i].tags, \"Investigator\")\n end\n else\n snaps[i].tags = nil\n end\n end\n end\n self.setSnapPoints(snaps)\nend\n\n-- Simple method to check if the given point is in a specified area. Local use only\n---@param point tts__Vector Point to check, only x and z values are relevant\n---@param bounds table Defined area to see if the point is within. See MAIN_PLAY_AREA for sample bounds definition.\n---@return boolean: True if the point is in the area defined by bounds\nfunction inArea(point, bounds)\n return (point.x \u003c bounds.upperLeft.x\n and point.x \u003e bounds.lowerRight.x\n and point.z \u003c bounds.upperLeft.z\n and point.z \u003e bounds.lowerRight.z)\nend\n\n-- called by custom data helpers to add player card data\n---@param args table Contains only one entry, the GUID of the custom data helper\nfunction updatePlayerCards(args)\n local customDataHelper = getObjectFromGUID(args[1])\n local playerCardData = customDataHelper.getTable(\"PLAYER_CARD_DATA\")\n tokenManager.addPlayerCardData(playerCardData)\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat to the first empty spot from the right \n ---@param matColor string Playermat that triggered this\n ---@param position tts__Vector Position for the encounter card\n MythosAreaApi.drawEncounterCard = function(matColor, position)\n getMythosArea().call(\"drawEncounterCard\", { matColor = matColor, position = position })\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/NavigationOverlayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local NavigationOverlayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getNOHandler()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"NavigationOverlayHandler\")\n end\n\n -- copies the visibility for the Navigation overlay\n ---@param startColor string Color of the player to copy from\n ---@param targetColor string Color of the targeted player\n NavigationOverlayApi.copyVisibility = function(startColor, targetColor)\n getNOHandler().call(\"copyVisibility\", {\n startColor = startColor,\n targetColor = targetColor\n })\n end\n\n -- changes the Navigation Overlay view (\"Full View\" --\u003e \"Play Areas\" --\u003e \"Closed\" etc.)\n ---@param playerColor string Color of the player to update the visibility for\n NavigationOverlayApi.cycleVisibility = function(playerColor)\n getNOHandler().call(\"cycleVisibility\", playerColor)\n end\n\n -- loads the specified camera for a player\n ---@param player tts__Player Player whose camera should be moved\n ---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to\n NavigationOverlayApi.loadCamera = function(player, camera)\n getNOHandler().call(\"loadCameraFromApi\", {\n player = player,\n camera = camera\n })\n end\n\n return NavigationOverlayApi\nend\nend)\n__bundle_register(\"core/token/TokenChecker\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local CHAOS_TOKEN_NAMES = {\n [\"Elder Sign\"] = true,\n [\"+1\"] = true,\n [\"0\"] = true,\n [\"-1\"] = true,\n [\"-2\"] = true,\n [\"-3\"] = true,\n [\"-4\"] = true,\n [\"-5\"] = true,\n [\"-6\"] = true,\n [\"-7\"] = true,\n [\"-8\"] = true,\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n [\"Auto-fail\"] = true,\n [\"Bless\"] = true,\n [\"Curse\"] = true,\n [\"Frost\"] = true\n }\n\n local TokenChecker = {}\n\n -- returns true if the passed object is a chaos token (by name)\n TokenChecker.isChaosToken = function(obj)\n if obj.type == \"Tile\" and CHAOS_TOKEN_NAMES[obj.getName()] then\n return true\n else\n return false\n end\n end\n\n return TokenChecker\nend\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned)\n -- token starts in state 1, so don't attempt to change it to avoid error\n if tokenValue ~= 1 then\n spawned.setState(tokenValue)\n end\n end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot? table New rotation for the object\n ---@param below? boolean Should the object be placed below an existing deck?\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot, below)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local offset = 0.5\n local newPos = Vector(pos) + Vector(0, offset, 0)\n\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n if below then\n newPos = Vector(pos):setAt(\"y\", bounds.center.y - bounds.size.y / 2)\n else\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n end\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScriptState": "{\"activeInvestigatorId\":\"00000\",\"isDrawButtonVisible\":false,\"playerColor\":\"Orange\",\"slotData\":[\"any\",\"any\",\"any\",\"Tarot\",\"Hand (left)\",\"Hand (right)\",\"Ally\",\"any\",\"any\",\"any\",\"Accessory\",\"Arcane\",\"Arcane\",\"Body\"]}", "MeasureMovement": false, "Memo": "Orange", "Name": "Custom_Tile", @@ -51105,9 +51115,9 @@ }, { "Position": { - "x": -0.631, + "x": 1.758, "y": 0.1, - "z": 0.551 + "z": 0.04 }, "Tags": [ "Asset" @@ -51115,39 +51125,9 @@ }, { "Position": { - "x": -0.616, - "y": 0.102, - "z": 0.024 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": -0.177, - "y": 0.101, - "z": 0.032 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": -0.174, - "y": 0.099, - "z": 0.551 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": 0.212, + "x": 1.371, "y": 0.1, - "z": 0.559 + "z": 0.038 }, "Tags": [ "Asset" @@ -51155,7 +51135,7 @@ }, { "Position": { - "x": 0.217, + "x": 0.98, "y": 0.1, "z": 0.035 }, @@ -51175,28 +51155,8 @@ }, { "Position": { - "x": 0.605, + "x": 0.217, "y": 0.1, - "z": 0.555 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": 0.977, - "y": 0.099, - "z": 0.556 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": 0.98, - "y": 0.099, "z": 0.035 }, "Tags": [ @@ -51205,9 +51165,9 @@ }, { "Position": { - "x": 1.371, + "x": -0.177, "y": 0.1, - "z": 0.038 + "z": 0.032 }, "Tags": [ "Asset" @@ -51215,9 +51175,9 @@ }, { "Position": { - "x": 1.371, - "y": 0.099, - "z": 0.558 + "x": -0.616, + "y": 0.1, + "z": 0.024 }, "Tags": [ "Asset" @@ -51235,9 +51195,59 @@ }, { "Position": { - "x": 1.758, - "y": 0.101, - "z": 0.04 + "x": 1.371, + "y": 0.1, + "z": 0.558 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": 0.977, + "y": 0.1, + "z": 0.556 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": 0.605, + "y": 0.1, + "z": 0.555 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": 0.212, + "y": 0.1, + "z": 0.559 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": -0.174, + "y": 0.1, + "z": 0.551 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": -0.631, + "y": 0.1, + "z": 0.551 }, "Tags": [ "Asset" @@ -51377,7 +51387,7 @@ }, "ImageScalar": 1, "ImageSecondaryURL": "", - "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037357630681963618/E7271737B19CE0BFAAA382BEEEF497FE3E06ECC1/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/", "WidthScale": 0 }, "Description": "", @@ -51391,8 +51401,8 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/Playmat\")\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat\n ---@param mat tts__Object Playermat that triggered this\n ---@param alwaysFaceUp boolean Whether the card should be drawn face-up\n MythosAreaApi.drawEncounterCard = function(mat, alwaysFaceUp)\n getMythosArea().call(\"drawEncounterCard\", {mat = mat, alwaysFaceUp = alwaysFaceUp})\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"core/NavigationOverlayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local NavigationOverlayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getNOHandler()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"NavigationOverlayHandler\")\n end\n\n -- copies the visibility for the Navigation overlay\n ---@param startColor string Color of the player to copy from\n ---@param targetColor string Color of the targeted player\n NavigationOverlayApi.copyVisibility = function(startColor, targetColor)\n getNOHandler().call(\"copyVisibility\", {\n startColor = startColor,\n targetColor = targetColor\n })\n end\n\n -- changes the Navigation Overlay view (\"Full View\" --\u003e \"Play Areas\" --\u003e \"Closed\" etc.)\n ---@param playerColor string Color of the player to update the visibility for\n NavigationOverlayApi.cycleVisibility = function(playerColor)\n getNOHandler().call(\"cycleVisibility\", playerColor)\n end\n\n -- loads the specified camera for a player\n ---@param player tts__Player Player whose camera should be moved\n ---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to\n NavigationOverlayApi.loadCamera = function(player, camera)\n getNOHandler().call(\"loadCameraFromApi\", {\n player = player,\n camera = camera\n })\n end\n\n return NavigationOverlayApi\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/token/TokenChecker\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local CHAOS_TOKEN_NAMES = {\n [\"Elder Sign\"] = true,\n [\"+1\"] = true,\n [\"0\"] = true,\n [\"-1\"] = true,\n [\"-2\"] = true,\n [\"-3\"] = true,\n [\"-4\"] = true,\n [\"-5\"] = true,\n [\"-6\"] = true,\n [\"-7\"] = true,\n [\"-8\"] = true,\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n [\"Auto-fail\"] = true,\n [\"Bless\"] = true,\n [\"Curse\"] = true,\n [\"Frost\"] = true\n }\n\n local TokenChecker = {}\n\n -- returns true if the passed object is a chaos token (by name)\n TokenChecker.isChaosToken = function(obj)\n if obj.type == \"Tile\" and CHAOS_TOKEN_NAMES[obj.getName()] then\n return true\n else\n return false\n end\n end\n\n return TokenChecker\nend\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror\n -- tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned) spawned.setState(tokenValue) end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"playermat/Playmat\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal deckLib = require(\"util/DeckLib\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal navigationOverlayApi = require(\"core/NavigationOverlayApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenChecker = require(\"core/token/TokenChecker\")\nlocal tokenManager = require(\"core/token/TokenManager\")\n\n-- we use this to turn off collision handling until onLoad() is complete\nlocal collisionEnabled = false\n\n-- x-Values for discard buttons\nlocal DISCARD_BUTTON_OFFSETS = {-1.365, -0.91, -0.455, 0, 0.455, 0.91}\n\nlocal SEARCH_AROUND_SELF_X_BUFFER = 8\n\n-- defined areas for object searching\nlocal MAIN_PLAY_AREA = {\n upperLeft = {\n x = 1.98,\n z = 0.736\n },\n lowerRight = {\n x = -0.79,\n z = -0.39\n }\n}\nlocal INVESTIGATOR_AREA = {\n upperLeft = {\n x = -1.084,\n z = 0.06517\n },\n lowerRight = {\n x = -1.258,\n z = -0.0805\n }\n}\nlocal THREAT_AREA = {\n upperLeft = {\n x = 1.53,\n z = -0.34\n },\n lowerRight = {\n x = -1.13,\n z = -0.92\n }\n}\nlocal DECK_DISCARD_AREA = {\n upperLeft = {\n x = -1.62,\n z = 0.855\n },\n lowerRight = {\n x = -2.02,\n z = -0.245\n },\n center = {\n x = -1.82,\n y = 0.5,\n z = 0.305\n },\n size = {\n x = 0.4,\n y = 3,\n z = 1.1\n }\n}\n\n-- local position of draw and discard pile\nlocal DRAW_DECK_POSITION = { x = -1.82, y = 0.1, z = 0 }\nlocal DISCARD_PILE_POSITION = { x = -1.82, y = 0.1, z = 0.61 }\n\n-- global position of encounter discard pile\nlocal ENCOUNTER_DISCARD_POSITION = { x = -3.85, y = 1.5, z = 10.38}\n\n-- global variable so it can be reset by the Clean Up Helper\nactiveInvestigatorId = \"00000\"\n\n-- table of type-object reference pairs of all owned objects\nlocal ownedObjects = {}\nlocal matColor = self.getMemo()\n\n-- variable to track the status of the \"Show Draw Button\" option\nlocal isDrawButtonVisible = false\n\n-- global variable to report \"Dream-Enhancing Serum\" status\nisDES = false\n\nfunction onSave()\n return JSON.encode({\n playerColor = playerColor,\n activeInvestigatorId = activeInvestigatorId,\n isDrawButtonVisible = isDrawButtonVisible\n })\nend\n\nfunction onLoad(saveState)\n self.interactable = false\n\n -- get object references to owned objects\n ownedObjects = guidReferenceApi.getObjectsByOwner(matColor)\n\n -- button creation\n for i = 1, 6 do\n makeDiscardButton(DISCARD_BUTTON_OFFSETS[i], i)\n end\n\n self.createButton({\n click_function = \"drawEncounterCard\",\n function_owner = self,\n position = {-1.84, 0, -0.65},\n rotation = {0, 80, 0},\n width = 265,\n height = 190\n })\n\n self.createButton({\n click_function = \"drawChaosTokenButton\",\n function_owner = self,\n position = {1.85, 0, -0.74},\n rotation = {0, -45, 0},\n width = 135,\n height = 135\n })\n\n self.createButton({\n label = \"Upkeep\",\n click_function = \"doUpkeep\",\n function_owner = self,\n position = {1.84, 0.1, -0.44},\n scale = {0.12, 0.12, 0.12},\n width = 800,\n height = 280,\n font_size = 180\n })\n\n -- save state loading\n local state = JSON.decode(saveState)\n if state ~= nil then\n playerColor = state.playerColor\n activeInvestigatorId = state.activeInvestigatorId\n isDrawButtonVisible = state.isDrawButtonVisible\n end\n\n showDrawButton(isDrawButtonVisible)\n math.randomseed(os.time())\n Wait.time(function() collisionEnabled = true end, 0.1)\nend\n\n---------------------------------------------------------\n-- utility functions\n---------------------------------------------------------\n\n-- searches an area and optionally filters the result\nfunction searchArea(origin, size, filter)\n return searchLib.inArea(origin, self.getRotation(), size, filter)\nend\n\n-- finds all objects on the playmat and associated set aside zone.\nfunction searchAroundSelf(filter)\n local bounds = self.getBoundsNormalized()\n -- Increase the width to cover the set aside zone\n bounds.size.x = bounds.size.x + SEARCH_AROUND_SELF_X_BUFFER\n bounds.size.y = 1\n -- Since the cast is centered on the position, shift left or right to keep the non-set aside edge\n -- of the cast at the edge of the playmat\n -- setAsideDirection accounts for the set aside zone being on the left or right, depending on the\n -- table position of the playmat\n local setAsideDirection = bounds.center.z \u003e 0 and 1 or -1\n local localCenter = self.positionToLocal(bounds.center)\n localCenter.x = localCenter.x + setAsideDirection * SEARCH_AROUND_SELF_X_BUFFER / 2 / self.getScale().x\n return searchArea(self.positionToWorld(localCenter), bounds.size, filter)\nend\n\n-- searches the area around the draw deck and discard pile\nfunction searchDeckAndDiscardArea(filter)\n local pos = self.positionToWorld(DECK_DISCARD_AREA.center)\n local scale = self.getScale()\n local size = {\n x = DECK_DISCARD_AREA.size.x * scale.x,\n y = DECK_DISCARD_AREA.size.y, \n z = DECK_DISCARD_AREA.size.z * scale.z\n }\n return searchArea(pos, size, filter)\nend\n\nfunction doNotReady(card)\n return card.getVar(\"do_not_ready\") or false\nend\n\n-- rounds a number to the specified amount of decimal places\n---@param num number Initial value\n---@param numDecimalPlaces number Amount of decimal places\nfunction round(num, numDecimalPlaces)\n local mult = 10^(numDecimalPlaces or 0)\n return math.floor(num * mult + 0.5) / mult\nend\n\n---------------------------------------------------------\n-- Discard buttons\n---------------------------------------------------------\n\n-- handles discarding for a list of objects\n---@param objList table List of objects to discard\nfunction discardListOfObjects(objList)\n for _, obj in ipairs(objList) do\n if obj.type == \"Card\" or obj.type == \"Deck\" then\n if obj.hasTag(\"PlayerCard\") then\n deckLib.placeOrMergeIntoDeck(obj, returnGlobalDiscardPosition(), self.getRotation())\n else\n deckLib.placeOrMergeIntoDeck(obj, ENCOUNTER_DISCARD_POSITION, {x = 0, y = -90, z = 0})\n end\n -- put chaos tokens back into bag (e.g. Unrelenting)\n elseif tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n -- don't touch locked objects (like the table etc.)\n elseif not obj.getLock() then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n-- build a discard button to discard from searchPosition (number must be unique)\nfunction makeDiscardButton(xValue, number)\n local position = { xValue, 0.1, -0.94}\n local searchPosition = {-position[1], position[2], position[3] + 0.32}\n local handlerName = 'handler' .. number\n self.setVar(handlerName, function()\n local cardSizeSearch = {2, 1, 3.2}\n local globalSearchPosition = self.positionToWorld(searchPosition)\n local searchResult = searchArea(globalSearchPosition, cardSizeSearch)\n return discardListOfObjects(searchResult)\n end)\n self.createButton({\n label = \"Discard\",\n click_function = handlerName,\n function_owner = self,\n position = position,\n scale = {0.12, 0.12, 0.12},\n width = 900,\n height = 350,\n font_size = 220\n })\nend\n\n---------------------------------------------------------\n-- Upkeep button\n---------------------------------------------------------\n\n-- calls the Upkeep function with correct parameter\nfunction doUpkeepFromHotkey(color)\n doUpkeep(_, color)\nend\n\nfunction doUpkeep(_, clickedByColor, isRightClick)\n if isRightClick then\n changeColor(clickedByColor)\n return\n end\n\n -- send messages to player who clicked button if no seated player found\n messageColor = Player[playerColor].seated and playerColor or clickedByColor\n\n -- unexhaust cards in play zone, flip action tokens and find forcedLearning\n local forcedLearning = false\n local rot = self.getRotation()\n for _, obj in ipairs(searchAroundSelf()) do\n if obj.getDescription() == \"Action Token\" and obj.is_face_down then\n obj.flip()\n elseif obj.type == \"Card\" and not inArea(self.positionToLocal(obj.getPosition()), INVESTIGATOR_AREA) then\n local cardMetadata = JSON.decode(obj.getGMNotes()) or {}\n if not doNotReady(obj) then\n local cardRotation = round(obj.getRotation().y, 0) - rot.y\n local yRotDiff = 0\n\n if cardRotation \u003c 0 then\n cardRotation = cardRotation + 360\n end\n\n -- rotate cards to the next multiple of 90° towards 0°\n if cardRotation \u003e 90 and cardRotation \u003c= 180 then\n yRotDiff = 90\n elseif cardRotation \u003c 270 and cardRotation \u003e 180 then\n yRotDiff = 270\n end\n\n -- set correct rotation for face-down cards\n rot.z = obj.is_face_down and 180 or 0\n obj.setRotation({rot.x, rot.y + yRotDiff, rot.z})\n end\n if cardMetadata.id == \"08031\" then\n forcedLearning = true\n end\n if cardMetadata.uses ~= nil then\n tokenManager.maybeReplenishCard(obj, cardMetadata.uses, self)\n end\n end\n end\n\n -- flip investigator mini-card and summoned servitor mini-card\n -- (all characters allowed to account for custom IDs - e.g. 'Z0000' for TTS Zoop generated IDs)\n local miniId = string.match(activeInvestigatorId, \".....\") .. \"-m\"\n for _, obj in ipairs(getObjects()) do\n if obj.type == \"Card\" and obj.is_face_down then\n local notes = JSON.decode(obj.getGMNotes())\n if notes ~= nil and notes.type == \"Minicard\" and (notes.id == miniId or notes.id == \"09080-m\") then\n obj.flip()\n end\n end\n end\n\n -- gain a resource (or two if playing Jenny Barnes)\n if string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"02003\" then\n updateCounter({type = \"ResourceCounter\", modifier = 2})\n printToColor(\"Gaining 2 resources (Jenny)\", messageColor)\n else\n updateCounter({type = \"ResourceCounter\", modifier = 1})\n end\n\n -- draw a card (with handling for Patrice and Forced Learning)\n if activeInvestigatorId == \"06005\" then\n if forcedLearning then\n printToColor(\"Wow, did you really take 'Versatile' to play Patrice with 'Forced Learning'? Choose which draw replacement effect takes priority and draw cards accordingly.\", messageColor)\n else\n local handSize = #Player[playerColor].getHandObjects()\n if handSize \u003c 5 then\n local cardsToDraw = 5 - handSize\n printToColor(\"Drawing \" .. cardsToDraw .. \" cards (Patrice)\", messageColor)\n drawCardsWithReshuffle(cardsToDraw)\n end\n end\n elseif forcedLearning then\n printToColor(\"Drawing 2 cards, discard 1 (Forced Learning)\", messageColor)\n drawCardsWithReshuffle(2)\n elseif activeInvestigatorId == \"89001\" then\n printToColor(\"Drawing 2 cards (Subject 5U-21)\", messageColor)\n drawCardsWithReshuffle(2)\n else\n drawCardsWithReshuffle(1)\n end\nend\n\n-- function for \"draw 1 button\" (that can be added via option panel)\nfunction doDrawOne(_, color)\n -- send messages to player who clicked button if no seated player found\n messageColor = Player[playerColor].seated and playerColor or color\n drawCardsWithReshuffle(1)\nend\n\n-- draw X cards (shuffle discards if necessary)\nfunction drawCardsWithReshuffle(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n\n -- Norman Withers handling\n local harbinger = false\n if deckAreaObjects.topCard and deckAreaObjects.topCard.getName() == \"The Harbinger\" then\n harbinger = true\n elseif deckAreaObjects.draw and not deckAreaObjects.draw.is_face_down then\n local cards = deckAreaObjects.draw.getObjects()\n if cards[#cards].name == \"The Harbinger\" then\n harbinger = true\n end\n end\n\n if harbinger then\n printToColor(\"The Harbinger is on top of your deck, not drawing cards\", messageColor)\n return\n end\n\n local topCardDetected = false\n if deckAreaObjects.topCard ~= nil then\n deckAreaObjects.topCard.deal(1, playerColor)\n topCardDetected = true\n numCards = numCards - 1\n if numCards == 0 then\n flipTopCardFromDeck()\n return\n end\n end\n\n local deckSize = 1\n if deckAreaObjects.draw == nil then\n deckSize = 0\n elseif deckAreaObjects.draw.type == \"Deck\" then\n deckSize = #deckAreaObjects.draw.getObjects()\n end\n\n if deckSize \u003e= numCards then\n drawCards(numCards)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n else\n drawCards(deckSize)\n if deckAreaObjects.discard ~= nil then\n shuffleDiscardIntoDeck()\n Wait.time(function()\n drawCards(numCards - deckSize)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n end, 1)\n end\n printToColor(\"Take 1 horror (drawing card from empty deck)\", messageColor)\n end\nend\n\n-- get the draw deck and discard pile objects and returns the references\nfunction getDeckAreaObjects()\n local deckAreaObjects = {}\n for _, object in ipairs(searchDeckAndDiscardArea(\"isCardOrDeck\")) do\n if self.positionToLocal(object.getPosition()).z \u003e 0.5 then\n deckAreaObjects.discard = object\n -- Norman Withers handling\n elseif object.type == \"Card\" and not object.is_face_down then\n deckAreaObjects.topCard = object\n else\n deckAreaObjects.draw = object\n end\n end\n return deckAreaObjects\nend\n\nfunction drawCards(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.draw then\n deckAreaObjects.draw.deal(numCards, playerColor)\n end\nend\n\nfunction shuffleDiscardIntoDeck()\n local deckAreaObjects = getDeckAreaObjects()\n if not deckAreaObjects.discard.is_face_down then\n deckAreaObjects.discard.flip()\n end\n deckAreaObjects.discard.shuffle()\n deckAreaObjects.discard.setPositionSmooth(self.positionToWorld(DRAW_DECK_POSITION), false, false)\nend\n\n-- utility function for Norman Withers to flip the top card to the revealed side\nfunction flipTopCardFromDeck()\n Wait.time(function()\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.topCard then\n elseif deckAreaObjects.draw then\n if deckAreaObjects.draw.type == \"Card\" then\n deckAreaObjects.draw.flip()\n else\n -- get bounds to know the height of the deck\n local bounds = deckAreaObjects.draw.getBounds()\n local pos = bounds.center + Vector(0, bounds.size.y / 2 + 0.2, 0)\n deckAreaObjects.draw.takeObject({ position = pos, flip = true })\n end\n end\n end, 0.1)\nend\n\n-- discard a random non-hidden card from hand\nfunction doDiscardOne()\n local hand = Player[playerColor].getHandObjects()\n if #hand == 0 then\n broadcastToAll(\"Cannot discard from empty hand!\", \"Red\")\n else\n local choices = {}\n for i = 1, #hand do\n local notes = JSON.decode(hand[i].getGMNotes())\n if notes ~= nil then\n if notes.hidden ~= true then\n table.insert(choices, i)\n end\n else\n table.insert(choices, i)\n end\n end\n\n if #choices == 0 then\n broadcastToAll(\"Hidden cards can't be randomly discarded.\", \"Orange\")\n return\n end\n\n -- get a random non-hidden card (from the \"choices\" table)\n local num = math.random(1, #choices)\n deckLib.placeOrMergeIntoDeck(hand[choices[num]], returnGlobalDiscardPosition(), self.getRotation())\n\n local playerName = Player[playerColor].steam_name or playerColor\n broadcastToAll(playerName .. \" randomly discarded card \" .. choices[num] .. \"/\" .. #hand .. \".\", \"White\")\n end\nend\n\n---------------------------------------------------------\n-- color related functions\n---------------------------------------------------------\n\n-- changes the player color\nfunction changeColor(clickedByColor)\n local colorList = {\n \"White\",\n \"Brown\",\n \"Red\",\n \"Orange\",\n \"Yellow\",\n \"Green\",\n \"Teal\",\n \"Blue\",\n \"Purple\",\n \"Pink\"\n }\n\n -- remove existing colors from the list of choices\n for _, existingColor in ipairs(Player.getAvailableColors()) do\n for i, newColor in ipairs(colorList) do\n if existingColor == newColor then\n table.remove(colorList, i)\n end\n end\n end\n\n -- show the option dialog for color selection to the player that triggered this\n Player[clickedByColor].showOptionsDialog(\"Select a new color:\", colorList, _, function(color)\n -- update the color of the hand zone\n local handZone = ownedObjects.HandZone\n handZone.setValue(color)\n\n -- if the seated player clicked this, reseat him to the new color\n if clickedByColor == playerColor then\n navigationOverlayApi.copyVisibility(playerColor, color)\n Player[playerColor].changeColor(color)\n end\n\n -- update the internal variable\n playerColor = color\n end)\nend\n\n---------------------------------------------------------\n-- playmat token spawning\n---------------------------------------------------------\n\n-- Finds all customizable cards in this play area and updates their metadata based on the selections\n-- on the matching upgrade sheet.\n-- This method is theoretically O(n^2), and should be used sparingly. In practice it will only be\n-- called when a checkbox is added or removed in-game (which should be rare), and is bounded by the\n-- number of customizable cards in play.\nfunction syncAllCustomizableCards()\n for _, card in ipairs(searchAroundSelf(\"isCard\")) do\n syncCustomizableMetadata(card)\n end\nend\n\nfunction syncCustomizableMetadata(card)\n local cardMetadata = JSON.decode(card.getGMNotes()) or { }\n if cardMetadata == nil or cardMetadata.customizations == nil then\n return\n end\n for _, upgradeSheet in ipairs(searchAroundSelf(\"isCard\")) do\n local upgradeSheetMetadata = JSON.decode(upgradeSheet.getGMNotes()) or { }\n if upgradeSheetMetadata.id == (cardMetadata.id .. \"-c\") then\n for i, customization in ipairs(cardMetadata.customizations) do\n if customization.replaces ~= nil and customization.replaces.uses ~= nil then\n -- Allowed use of call(), no APIs for individual cards\n if upgradeSheet.call(\"isUpgradeActive\", i) then\n cardMetadata.uses = customization.replaces.uses\n card.setGMNotes(JSON.encode(cardMetadata))\n else\n -- TODO: Get the original metadata to restore it... maybe. This should only be\n -- necessary in the very unlikely case that a user un-checks a previously-full upgrade\n -- row while the card is in play. It will be much easier once the AllPlayerCardsApi is\n -- in place, so defer until it is\n end\n end\n end\n end\n end\nend\n\nfunction spawnTokensFor(object)\n local extraUses = { }\n if activeInvestigatorId == \"03004\" then\n extraUses[\"Charge\"] = 1\n end\n\n tokenManager.spawnForCard(object, extraUses)\nend\n\nfunction onCollisionEnter(collisionInfo)\n local object = collisionInfo.collision_object\n\n -- only continue if loading is completed\n if not collisionEnabled then return end\n\n -- only continue for cards\n if object.type ~= \"Card\" then return end\n\n -- detect if \"Dream-Enhancing Serum\" is placed\n if object.getName() == \"Dream-Enhancing Serum\" then isDES = true end\n\n maybeUpdateActiveInvestigator(object)\n syncCustomizableMetadata(object)\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n elseif shouldSpawnTokens(object) then\n spawnTokensFor(object)\n end\nend\n\n-- detect if \"Dream-Enhancing Serum\" is removed\nfunction onCollisionExit(collisionInfo)\n if collisionInfo.collision_object.getName() == \"Dream-Enhancing Serum\" then isDES = false end\nend\n\n-- checks if tokens should be spawned for the provided card\nfunction shouldSpawnTokens(card)\n if card.is_face_down then\n return false\n end\n\n local localCardPos = self.positionToLocal(card.getPosition())\n local metadata = JSON.decode(card.getGMNotes())\n\n -- If no metadata we don't know the type, so only spawn in the main area\n if metadata == nil then\n return inArea(localCardPos, MAIN_PLAY_AREA)\n end\n\n -- Spawn tokens for assets and events on the main area\n if inArea(localCardPos, MAIN_PLAY_AREA)\n and (metadata.type == \"Asset\"\n or metadata.type == \"Event\") then\n return true\n end\n\n -- Spawn tokens for all encounter types in the threat area\n if inArea(localCardPos, THREAT_AREA)\n and (metadata.type == \"Treachery\"\n or metadata.type == \"Enemy\"\n or metadata.weakness) then\n return true\n end\n\n return false\nend\n\nfunction onObjectEnterContainer(container, object)\n if object.type ~= \"Card\" then return end\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n end\nend\n\n-- removes tokens from the provided card/deck\nfunction removeTokensFromObject(object)\n if object.hasTag(\"CardThatSeals\") then\n local func = object.getVar(\"resetSealedTokens\") -- check if function exists (it won't for older custom content)\n if func ~= nil then\n object.call(\"resetSealedTokens\")\n end\n end\n\n for _, obj in ipairs(searchLib.onObject(object)) do\n if tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n elseif obj.getGUID() ~= \"4ee1f2\" and -- table\n obj ~= self and\n obj.type ~= \"Deck\" and\n obj.type ~= \"Card\" and\n obj.memo ~= nil and\n obj.getLock() == false and\n obj.getDescription() ~= \"Action Token\" then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n---------------------------------------------------------\n-- investigator ID grabbing and skill tracker\n---------------------------------------------------------\n\nfunction maybeUpdateActiveInvestigator(card)\n if not inArea(self.positionToLocal(card.getPosition()), INVESTIGATOR_AREA) then return end\n\n local notes = JSON.decode(card.getGMNotes())\n local class\n\n if notes ~= nil and notes.type == \"Investigator\" and notes.id ~= nil then\n if notes.id == activeInvestigatorId then return end\n class = notes.class\n activeInvestigatorId = notes.id\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", {\n notes.willpowerIcons,\n notes.intellectIcons,\n notes.combatIcons,\n notes.agilityIcons\n })\n elseif activeInvestigatorId ~= \"00000\" then\n class = \"Neutral\"\n activeInvestigatorId = \"00000\"\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", {1, 1, 1, 1})\n else\n return\n end\n\n -- change state of action tokens\n local search = searchArea(self.positionToWorld({-1.1, 0.05, -0.27}), {4, 1, 1})\n local smallToken = nil\n local STATE_TABLE = {\n [\"Guardian\"] = 1,\n [\"Seeker\"] = 2,\n [\"Rogue\"] = 3,\n [\"Mystic\"] = 4,\n [\"Survivor\"] = 5,\n [\"Neutral\"] = 6\n }\n\n for _, obj in ipairs(search) do\n if obj.getDescription() == \"Action Token\" and obj.getStateId() \u003e 0 then\n if obj.getScale().x \u003c 0.4 then\n smallToken = obj\n else\n setObjectState(obj, STATE_TABLE[class])\n end\n end\n end\n\n -- update the small token with special action for certain investigators\n local SPECIAL_ACTIONS = {\n [\"04002\"] = 8, -- Ursula Downs\n [\"01002\"] = 9, -- Daisy Walker\n [\"01502\"] = 9, -- Daisy Walker\n [\"01002-pb\"] = 9, -- Daisy Walker\n [\"06003\"] = 10, -- Tony Morgan\n [\"04003\"] = 11, -- Finn Edwards\n [\"08016\"] = 14 -- Bob Jenkins\n }\n\n if smallToken ~= nil then\n setObjectState(smallToken, SPECIAL_ACTIONS[activeInvestigatorId] or STATE_TABLE[class])\n end\nend\n\nfunction setObjectState(obj, stateId)\n if obj.getStateId() ~= stateId then obj.setState(stateId) end\nend\n\n---------------------------------------------------------\n-- manipulation of owned objects\n---------------------------------------------------------\n\n-- updates the specific owned counter\n---@param param table Contains the information to update:\n--- type: String Counter to target\n--- newValue: Number Value to set the counter to\n--- modifier: Number If newValue is not provided, the existing value will be adjusted by this modifier\nfunction updateCounter(param)\n local counter = ownedObjects[param.type]\n if counter ~= nil then\n counter.call(\"updateVal\", param.newValue or (counter.getVar(\"val\") + param.modifier))\n else\n printToAll(param.type .. \" for \" .. matColor .. \" could not be found.\", \"Yellow\")\n end\nend\n\n-- returns the resource counter amount\n---@param type string Counter to target\nfunction getCounterValue(type)\n return ownedObjects[type].getVar(\"val\")\nend\n\n-- set investigator skill tracker to \"1, 1, 1, 1\"\nfunction resetSkillTracker()\n local obj = ownedObjects.InvestigatorSkillTracker\n if obj ~= nil then\n obj.call(\"updateStats\", { 1, 1, 1, 1 })\n else\n printToAll(\"Skill tracker for \" .. matColor .. \" playmat could not be found.\", \"Yellow\")\n end\nend\n\n---------------------------------------------------------\n-- calls to 'Global' / functions for calls from outside\n---------------------------------------------------------\n\nfunction drawChaosTokenButton(_, _, isRightClick)\n chaosBagApi.drawChaosToken(self, isRightClick)\nend\n\nfunction drawEncounterCard(_, _, isRightClick)\n mythosAreaApi.drawEncounterCard(self, isRightClick)\nend\n\nfunction returnGlobalDiscardPosition()\n return self.positionToWorld(DISCARD_PILE_POSITION)\nend\n\n-- Sets this playermat's draw 1 button to visible\n---@param visible boolean Whether the draw 1 button should be visible\nfunction showDrawButton(visible)\n isDrawButtonVisible = visible\n\n -- create the \"Draw 1\" button\n if isDrawButtonVisible then\n self.createButton({\n label = \"Draw 1\",\n click_function = \"doDrawOne\",\n function_owner = self,\n position = { 1.84, 0.1, -0.36 },\n scale = { 0.12, 0.12, 0.12 },\n width = 800,\n height = 280,\n font_size = 180\n })\n\n -- remove the \"Draw 1\" button\n else\n local buttons = self.getButtons()\n for i = 1, #buttons do\n if buttons[i].label == \"Draw 1\" then\n self.removeButton(buttons[i].index)\n end\n end\n end\nend\n\n-- shows / hides a clickable clue counter for this playmat and sets the correct amount of clues\n---@param showCounter boolean Whether the clickable clue counter should be visible\nfunction clickableClues(showCounter)\n local clickerPos = ownedObjects.ClickableClueCounter.getPosition()\n local clueCount = 0\n \n -- move clue counters\n local modY = showCounter and 0.525 or -0.525\n ownedObjects.ClickableClueCounter.setPosition(clickerPos + Vector(0, modY, 0))\n\n if showCounter then\n -- current clue count\n clueCount = ownedObjects.ClueCounter.getVar(\"exposedValue\")\n\n -- remove clues\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n\n -- set value for clue clickers\n ownedObjects.ClickableClueCounter.call(\"updateVal\", clueCount)\n else\n -- current clue count\n clueCount = ownedObjects.ClickableClueCounter.getVar(\"val\")\n\n -- spawn clues\n local pos = self.positionToWorld({x = -1.12, y = 0.05, z = 0.7})\n for i = 1, clueCount do\n pos.y = pos.y + 0.045 * i\n tokenManager.spawnToken(pos, \"clue\", self.getRotation())\n end\n end\nend\n\n-- removes all clues (moving tokens to the trash and setting counters to 0)\nfunction removeClues()\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n ownedObjects.ClickableClueCounter.call(\"updateVal\", 0)\nend\n\n-- reports the clue count\n---@param useClickableCounters boolean Controls which type of counter is getting checked\nfunction getClueCount(useClickableCounters)\n if useClickableCounters then\n return ownedObjects.ClickableClueCounter.getVar(\"val\")\n else\n return ownedObjects.ClueCounter.getVar(\"exposedValue\")\n end\nend\n\n-- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes\n-- is true, the main card slot snap points will only snap assets, while the investigator area point\n-- will only snap Investigators. If matchTypes is false, snap points will be reset to snap all cards.\n---@param matchTypes boolean Whether snap points should only snap for the matching card types.\nfunction setLimitSnapsByType(matchTypes)\n local snaps = self.getSnapPoints()\n for i, snap in ipairs(snaps) do\n local snapPos = snap.position\n if inArea(snapPos, MAIN_PLAY_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Asset\" }\n else\n table.insert(snaps[i].tags, \"Asset\")\n end\n else\n snaps[i].tags = nil\n end\n end\n if inArea(snapPos, INVESTIGATOR_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Investigator\" }\n else\n table.insert(snaps[i].tags, \"Investigator\")\n end\n else\n snaps[i].tags = nil\n end\n end\n end\n self.setSnapPoints(snaps)\nend\n\n-- Simple method to check if the given point is in a specified area. Local use only,\n---@param point tts__Vector Point to check, only x and z values are relevant\n---@param bounds table Defined area to see if the point is within. See MAIN_PLAY_AREA for sample\n-- bounds definition.\n---@return boolean: True if the point is in the area defined by bounds\nfunction inArea(point, bounds)\n return (point.x \u003c bounds.upperLeft.x\n and point.x \u003e bounds.lowerRight.x\n and point.z \u003c bounds.upperLeft.z\n and point.z \u003e bounds.lowerRight.z)\nend\n\n-- called by custom data helpers to add player card data\n---@param args table Contains only one entry, the GUID of the custom data helper\nfunction updatePlayerCards(args)\n local customDataHelper = getObjectFromGUID(args[1])\n local playerCardData = customDataHelper.getTable(\"PLAYER_CARD_DATA\")\n tokenManager.addPlayerCardData(playerCardData)\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot table New rotation for the object (optional)\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local newPos\n local offset = 0.5\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n else\n newPos = Vector(pos) + Vector(0, offset, 0)\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", - "LuaScriptState": "{\"activeInvestigatorId\":\"00000\",\"isDrawButtonVisible\":false,\"playerColor\":\"Green\"}", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/Playmat\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat to the first empty spot from the right \n ---@param matColor string Playermat that triggered this\n ---@param position tts__Vector Position for the encounter card\n MythosAreaApi.drawEncounterCard = function(matColor, position)\n getMythosArea().call(\"drawEncounterCard\", { matColor = matColor, position = position })\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"core/token/TokenChecker\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local CHAOS_TOKEN_NAMES = {\n [\"Elder Sign\"] = true,\n [\"+1\"] = true,\n [\"0\"] = true,\n [\"-1\"] = true,\n [\"-2\"] = true,\n [\"-3\"] = true,\n [\"-4\"] = true,\n [\"-5\"] = true,\n [\"-6\"] = true,\n [\"-7\"] = true,\n [\"-8\"] = true,\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n [\"Auto-fail\"] = true,\n [\"Bless\"] = true,\n [\"Curse\"] = true,\n [\"Frost\"] = true\n }\n\n local TokenChecker = {}\n\n -- returns true if the passed object is a chaos token (by name)\n TokenChecker.isChaosToken = function(obj)\n if obj.type == \"Tile\" and CHAOS_TOKEN_NAMES[obj.getName()] then\n return true\n else\n return false\n end\n end\n\n return TokenChecker\nend\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned)\n -- token starts in state 1, so don't attempt to change it to avoid error\n if tokenValue ~= 1 then\n spawned.setState(tokenValue)\n end\n end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"playermat/Playmat\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal deckLib = require(\"util/DeckLib\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal navigationOverlayApi = require(\"core/NavigationOverlayApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenChecker = require(\"core/token/TokenChecker\")\nlocal tokenManager = require(\"core/token/TokenManager\")\n\n-- we use this to turn off collision handling until onLoad() is complete\nlocal collisionEnabled = false\nlocal currentlyEditingSlots = false\n\n-- x-Values for discard buttons\nlocal DISCARD_BUTTON_X_START = -1.365\nlocal DISCARD_BUTTON_X_OFFSET = 0.455\n\nlocal SEARCH_AROUND_SELF_X_BUFFER = 8\n\n-- defined areas for object searching\nlocal MAIN_PLAY_AREA = {\n upperLeft = { x = 1.98, z = 0.736 },\n lowerRight = { x = -0.79, z = -0.39 }\n}\nlocal INVESTIGATOR_AREA = {\n upperLeft = { x = -1.084, z = 0.06517 },\n lowerRight = { x = -1.258, z = -0.0805 }\n}\nlocal THREAT_AREA = {\n upperLeft = { x = 1.53, z = -0.34 },\n lowerRight = { x = -1.13, z = -0.92 }\n}\nlocal DECK_DISCARD_AREA = {\n upperLeft = { x = -1.62, z = 0.855 },\n lowerRight = { x = -2.02, z = -0.245 },\n center = { x = -1.82, y = 0.5, z = 0.305 },\n size = { x = 0.4, y = 3, z = 1.1 }\n}\n\n-- local positions\nlocal DRAW_DECK_POSITION = { x = -1.82, y = 0.1, z = 0 }\nlocal DISCARD_PILE_POSITION = { x = -1.82, y = 0.1, z = 0.61 }\nlocal DRAWN_ENCOUNTER_POSITION = { x = 1.365, y = 0.5, z = -0.625 }\n\n-- global position of encounter discard pile\nlocal ENCOUNTER_DISCARD_POSITION = { x = -3.85, y = 1.5, z = 10.38 }\n\n-- used for the buttons on the right side of the playmat\n-- starts off with the data for the \"Upkeep\" button and will then be changed\nlocal buttonParameters = {\n label = \"Upkeep\",\n click_function = \"doUpkeep\",\n tooltip = \"Right-click to change color\",\n function_owner = self,\n position = { x = 1.82, y = 0.1, z = -0.45 },\n scale = { 0.12, 0.12, 0.12 },\n width = 1000,\n height = 280,\n font_size = 180\n}\n\n-- translation table for slot names to characters for special font\nlocal slotNameToChar = {\n [\"any\"] = \"\",\n [\"Accessory\"] = \"C\",\n [\"Ally\"] = \"E\",\n [\"Arcane\"] = \"G\",\n [\"Body\"] = \"K\",\n [\"Hand (right)\"] = \"M\",\n [\"Hand (left)\"] = \"M\",\n [\"Hand x2\"] = \"N\",\n [\"Tarot\"] = \"A\"\n}\n\n-- slot symbol for the respective slot (from top left to bottom right)\nlocal slotData = {}\nlocal defaultSlotData = {\n -- 1st row\n \"any\", \"any\", \"any\", \"Tarot\", \"Hand (left)\", \"Hand (right)\", \"Ally\",\n\n -- 2nd row\n \"any\", \"any\", \"any\", \"Accessory\", \"Arcane\", \"Arcane\", \"Body\"\n}\n\n-- global variable so it can be reset by the Clean Up Helper\nactiveInvestigatorId = \"00000\"\nlocal isDrawButtonVisible = false\n\n-- global variable to report \"Dream-Enhancing Serum\" status\nisDES = false\n\n-- table of type-object reference pairs of all owned objects\nlocal ownedObjects = {}\nlocal matColor = self.getMemo()\n\nfunction onSave()\n return JSON.encode({\n playerColor = playerColor,\n activeInvestigatorId = activeInvestigatorId,\n isDrawButtonVisible = isDrawButtonVisible,\n slotData = slotData\n })\nend\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n playerColor = loadedData.playerColor\n activeInvestigatorId = loadedData.activeInvestigatorId\n isDrawButtonVisible = loadedData.isDrawButtonVisible\n slotData = loadedData.slotData\n end\n\n self.interactable = false\n\n -- get object references to owned objects\n ownedObjects = guidReferenceApi.getObjectsByOwner(matColor)\n\n -- discard button creation\n for i = 1, 6 do\n makeDiscardButton(i)\n end\n\n self.createButton({\n click_function = \"drawEncounterCard\",\n function_owner = self,\n position = { -1.84, 0, -0.65 },\n rotation = { 0, 80, 0 },\n width = 265,\n height = 190\n })\n\n self.createButton({\n click_function = \"drawChaosTokenButton\",\n function_owner = self,\n position = { 1.85, 0, -0.74 },\n rotation = { 0, -45, 0 },\n width = 135,\n height = 135\n })\n\n -- Upkeep button: can use the default parameters for this\n self.createButton(buttonParameters)\n\n -- Slot editing button: modified default data\n buttonParameters.label = \"Edit Slots\"\n buttonParameters.click_function = \"toggleSlotEditing\"\n buttonParameters.tooltip = \"Right-click to reset slot symbols\"\n buttonParameters.position.z = 0.92\n self.createButton(buttonParameters)\n\n showDrawButton(isDrawButtonVisible)\n redrawSlotSymbols()\n math.randomseed(os.time())\n Wait.time(function() collisionEnabled = true end, 0.1)\nend\n\n---------------------------------------------------------\n-- utility functions\n---------------------------------------------------------\n\n-- searches an area and optionally filters the result\nfunction searchArea(origin, size, filter)\n return searchLib.inArea(origin, self.getRotation(), size, filter)\nend\n\n-- finds all objects on the playmat and associated set aside zone.\nfunction searchAroundSelf(filter)\n local bounds = self.getBoundsNormalized()\n -- Increase the width to cover the set aside zone\n bounds.size.x = bounds.size.x + SEARCH_AROUND_SELF_X_BUFFER\n bounds.size.y = 1\n -- Since the cast is centered on the position, shift left or right to keep the non-set aside edge\n -- of the cast at the edge of the playmat\n -- setAsideDirection accounts for the set aside zone being on the left or right, depending on the\n -- table position of the playmat\n local setAsideDirection = bounds.center.z \u003e 0 and 1 or -1\n local localCenter = self.positionToLocal(bounds.center)\n localCenter.x = localCenter.x + setAsideDirection * SEARCH_AROUND_SELF_X_BUFFER / 2 / self.getScale().x\n return searchArea(self.positionToWorld(localCenter), bounds.size, filter)\nend\n\n-- searches the area around the draw deck and discard pile\nfunction searchDeckAndDiscardArea(filter)\n local pos = self.positionToWorld(DECK_DISCARD_AREA.center)\n local scale = self.getScale()\n local size = {\n x = DECK_DISCARD_AREA.size.x * scale.x,\n y = DECK_DISCARD_AREA.size.y,\n z = DECK_DISCARD_AREA.size.z * scale.z\n }\n return searchArea(pos, size, filter)\nend\n\n-- rounds a number to the specified amount of decimal places\n---@param num number Initial value\n---@param numDecimalPlaces number Amount of decimal places\n---@return number: rounded number\nfunction round(num, numDecimalPlaces)\n local mult = 10 ^ (numDecimalPlaces or 0)\n return math.floor(num * mult + 0.5) / mult\nend\n\n-- edits the label of a button\n---@param oldLabel string Old label of the button\n---@param newLabel string New label of the button\nfunction editButtonLabel(oldLabel, newLabel)\n local buttons = self.getButtons()\n for i = 1, #buttons do\n if buttons[i].label == oldLabel then\n self.editButton({ index = buttons[i].index, label = newLabel })\n end\n end\nend\n\n-- updates the internal \"messageColor\" which is used for print/broadcast statements if no player is seated\n---@param clickedByColor string Colorstring of player who clicked a button\nfunction updateMessageColor(clickedByColor)\n messageColor = Player[playerColor].seated and playerColor or clickedByColor\nend\n\n---------------------------------------------------------\n-- Discard buttons\n---------------------------------------------------------\n\n-- handles discarding for a list of objects\n---@param objList table List of objects to discard\nfunction discardListOfObjects(objList)\n for _, obj in ipairs(objList) do\n if obj.type == \"Card\" or obj.type == \"Deck\" then\n if obj.hasTag(\"PlayerCard\") then\n deckLib.placeOrMergeIntoDeck(obj, returnGlobalDiscardPosition(), self.getRotation())\n else\n deckLib.placeOrMergeIntoDeck(obj, ENCOUNTER_DISCARD_POSITION, { x = 0, y = -90, z = 0 })\n end\n\n -- put chaos tokens back into bag (e.g. Unrelenting)\n elseif tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n\n -- don't touch locked objects (like the table etc.) or specific objects (like key tokens)\n elseif not obj.getLock() and not obj.hasTag(\"DontDiscard\") then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n-- build a discard button to discard from searchPosition\n---@param id number Index of the discard button (from left to right, must be unique)\nfunction makeDiscardButton(id)\n local xValue = DISCARD_BUTTON_X_START + (id - 1) * DISCARD_BUTTON_X_OFFSET\n local position = { xValue, 0.1, -0.94 }\n local searchPosition = { -position[1], position[2], position[3] + 0.32 }\n local handlerName = 'handler' .. id\n self.setVar(handlerName, function()\n local cardSizeSearch = { 2, 1, 3.2 }\n local globalSearchPosition = self.positionToWorld(searchPosition)\n local searchResult = searchArea(globalSearchPosition, cardSizeSearch)\n return discardListOfObjects(searchResult)\n end)\n self.createButton({\n label = \"Discard\",\n click_function = handlerName,\n function_owner = self,\n position = position,\n scale = { 0.12, 0.12, 0.12 },\n width = 900,\n height = 350,\n font_size = 220\n })\nend\n\n---------------------------------------------------------\n-- Upkeep button\n---------------------------------------------------------\n\n-- calls the Upkeep function with correct parameter\nfunction doUpkeepFromHotkey(clickedByColor)\n doUpkeep(_, clickedByColor)\nend\n\nfunction doUpkeep(_, clickedByColor, isRightClick)\n if isRightClick then\n changeColor(clickedByColor)\n return\n end\n\n updateMessageColor(clickedByColor)\n\n -- unexhaust cards in play zone, flip action tokens and find forcedLearning\n local forcedLearning = false\n local rot = self.getRotation()\n for _, obj in ipairs(searchAroundSelf()) do\n if obj.getDescription() == \"Action Token\" and obj.is_face_down then\n obj.flip()\n elseif obj.type == \"Card\" and not inArea(self.positionToLocal(obj.getPosition()), INVESTIGATOR_AREA) then\n local cardMetadata = JSON.decode(obj.getGMNotes()) or {}\n if not (obj.getVar(\"do_not_ready\") or false) then\n local cardRotation = round(obj.getRotation().y, 0) - rot.y\n local yRotDiff = 0\n\n if cardRotation \u003c 0 then\n cardRotation = cardRotation + 360\n end\n\n -- rotate cards to the next multiple of 90° towards 0°\n if cardRotation \u003e 90 and cardRotation \u003c= 180 then\n yRotDiff = 90\n elseif cardRotation \u003c 270 and cardRotation \u003e 180 then\n yRotDiff = 270\n end\n\n -- set correct rotation for face-down cards\n rot.z = obj.is_face_down and 180 or 0\n obj.setRotation({ rot.x, rot.y + yRotDiff, rot.z })\n end\n\n -- detect forced learning to handle card drawing accordingly\n if cardMetadata.id == \"08031\" then\n forcedLearning = true\n end\n\n -- maybe replenish uses on certain cards\n if cardMetadata.uses ~= nil then\n tokenManager.maybeReplenishCard(obj, cardMetadata.uses, self)\n end\n elseif obj.type == \"Deck\" and forcedLearning == false then\n -- check decks for forced learning\n for _, deepObj in ipairs(obj.getObjects()) do\n local cardMetadata = JSON.decode(deepObj.gm_notes) or {}\n if cardMetadata.id == \"08031\" then\n forcedLearning = true\n end\n end\n end\n end\n\n -- flip investigator mini-card and summoned servitor mini-card\n -- (all characters allowed to account for custom IDs - e.g. 'Z0000' for TTS Zoop generated IDs)\n local miniId = string.match(activeInvestigatorId, \".....\") .. \"-m\"\n for _, obj in ipairs(getObjects()) do\n if obj.type == \"Card\" and obj.is_face_down then\n local notes = JSON.decode(obj.getGMNotes())\n if notes ~= nil and notes.type == \"Minicard\" and (notes.id == miniId or notes.id == \"09080-m\") then\n obj.flip()\n end\n end\n end\n\n -- gain a resource (or two if playing Jenny Barnes)\n if string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"02003\" then\n updateCounter({ type = \"ResourceCounter\", modifier = 2 })\n printToColor(\"Gaining 2 resources (Jenny)\", messageColor)\n else\n updateCounter({ type = \"ResourceCounter\", modifier = 1 })\n end\n\n -- draw a card (with handling for Patrice and Forced Learning)\n if activeInvestigatorId == \"06005\" then\n if forcedLearning then\n printToColor(\"Wow, did you really take 'Versatile' to play Patrice with 'Forced Learning'?\"\n .. \" Choose which draw replacement effect takes priority and draw cards accordingly.\", messageColor)\n else\n local handSize = #Player[playerColor].getHandObjects()\n if handSize \u003c 5 then\n local cardsToDraw = 5 - handSize\n printToColor(\"Drawing \" .. cardsToDraw .. \" cards (Patrice)\", messageColor)\n drawCardsWithReshuffle(cardsToDraw)\n end\n end\n elseif forcedLearning then\n printToColor(\"Drawing 2 cards, discard 1 (Forced Learning)\", messageColor)\n drawCardsWithReshuffle(2)\n elseif activeInvestigatorId == \"89001\" then\n printToColor(\"Drawing 2 cards (Subject 5U-21)\", messageColor)\n drawCardsWithReshuffle(2)\n else\n drawCardsWithReshuffle(1)\n end\nend\n\n-- click function for \"draw 1 button\" (that can be added via option panel)\nfunction doDrawOne(_, clickedByColor)\n updateMessageColor(clickedByColor)\n drawCardsWithReshuffle(1)\nend\n\n-- draws the specified amount of cards (and shuffles the discard if necessary)\n---@param numCards number Number of cards to draw\nfunction drawCardsWithReshuffle(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n\n -- Norman Withers handling\n local harbinger = false\n if deckAreaObjects.topCard and deckAreaObjects.topCard.getName() == \"The Harbinger\" then\n harbinger = true\n elseif deckAreaObjects.draw and not deckAreaObjects.draw.is_face_down then\n local cards = deckAreaObjects.draw.getObjects()\n if cards[#cards].name == \"The Harbinger\" then\n harbinger = true\n end\n end\n\n if harbinger then\n printToColor(\"The Harbinger is on top of your deck, not drawing cards\", messageColor)\n return\n end\n\n local topCardDetected = false\n if deckAreaObjects.topCard ~= nil then\n deckAreaObjects.topCard.deal(1, playerColor)\n topCardDetected = true\n numCards = numCards - 1\n if numCards == 0 then\n flipTopCardFromDeck()\n return\n end\n end\n\n local deckSize = 1\n if deckAreaObjects.draw == nil then\n deckSize = 0\n elseif deckAreaObjects.draw.type == \"Deck\" then\n deckSize = #deckAreaObjects.draw.getObjects()\n end\n\n if deckSize \u003e= numCards then\n drawCards(numCards)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n else\n drawCards(deckSize)\n if deckAreaObjects.discard ~= nil then\n shuffleDiscardIntoDeck()\n Wait.time(function()\n drawCards(numCards - deckSize)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n end, 1)\n end\n printToColor(\"Take 1 horror (drawing card from empty deck)\", messageColor)\n end\nend\n\n-- get the draw deck and discard pile objects and returns the references\n---@return table: string-indexed table with references to the found objects\nfunction getDeckAreaObjects()\n local deckAreaObjects = {}\n for _, object in ipairs(searchDeckAndDiscardArea(\"isCardOrDeck\")) do\n if self.positionToLocal(object.getPosition()).z \u003e 0.5 then\n deckAreaObjects.discard = object\n -- Norman Withers handling\n elseif object.type == \"Card\" and not object.is_face_down then\n deckAreaObjects.topCard = object\n else\n deckAreaObjects.draw = object\n end\n end\n return deckAreaObjects\nend\n\n-- draws the specified number of cards (reshuffling of discard pile is handled separately)\n---@param numCards number Number of cards to draw\nfunction drawCards(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.draw then\n deckAreaObjects.draw.deal(numCards, playerColor)\n end\nend\n\nfunction shuffleDiscardIntoDeck()\n local deckAreaObjects = getDeckAreaObjects()\n if not deckAreaObjects.discard.is_face_down then\n deckAreaObjects.discard.flip()\n end\n deckAreaObjects.discard.shuffle()\n deckAreaObjects.discard.setPositionSmooth(self.positionToWorld(DRAW_DECK_POSITION), false, false)\nend\n\n-- utility function for Norman Withers to flip the top card to the revealed side\nfunction flipTopCardFromDeck()\n Wait.time(function()\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.topCard then\n elseif deckAreaObjects.draw then\n if deckAreaObjects.draw.type == \"Card\" then\n deckAreaObjects.draw.flip()\n else\n -- get bounds to know the height of the deck\n local bounds = deckAreaObjects.draw.getBounds()\n local pos = bounds.center + Vector(0, bounds.size.y / 2 + 0.2, 0)\n deckAreaObjects.draw.takeObject({ position = pos, flip = true })\n end\n end\n end, 0.1)\nend\n\n-- discard a random non-hidden card from hand\nfunction doDiscardOne()\n local hand = Player[playerColor].getHandObjects()\n if #hand == 0 then\n broadcastToColor(\"Cannot discard from empty hand!\", messageColor, \"Red\")\n else\n local choices = {}\n for i = 1, #hand do\n local notes = JSON.decode(hand[i].getGMNotes())\n if notes ~= nil then\n if notes.hidden ~= true then\n table.insert(choices, i)\n end\n else\n table.insert(choices, i)\n end\n end\n\n if #choices == 0 then\n broadcastToColor(\"Hidden cards can't be randomly discarded.\", messageColor, \"Orange\")\n return\n end\n\n -- get a random non-hidden card (from the \"choices\" table)\n local num = math.random(1, #choices)\n deckLib.placeOrMergeIntoDeck(hand[choices[num]], returnGlobalDiscardPosition(), self.getRotation())\n\n local playerName = Player[playerColor].steam_name or playerColor\n broadcastToAll(playerName .. \" randomly discarded card \" .. choices[num] .. \"/\" .. #hand .. \".\", \"White\")\n end\nend\n\n---------------------------------------------------------\n-- slot symbol displaying\n---------------------------------------------------------\n\n-- this will redraw the XML for the slot symbols based on the slotData table\nfunction redrawSlotSymbols()\n local xml = {}\n local snapId = 0\n\n -- use the snap point positions in the main play area for positions\n for _, snap in ipairs(self.getSnapPoints()) do\n if inArea(snap.position, MAIN_PLAY_AREA) then\n snapId = snapId + 1\n local slotName = slotData[snapId]\n\n -- conversion from regular coordinates to XML\n local x = snap.position.x * 100\n local y = snap.position.z * 100\n\n -- XML for a single slot (panel with text in the special font)\n local slotXML = {\n tag = \"Panel\",\n attributes = {\n id = \"slotPanel\" .. snapId,\n scale = \"0.1 0.1 1\",\n width = \"175\",\n height = \"175\",\n position = x .. \" \" .. y .. \" -11\"\n },\n children = {\n {\n tag = \"Text\",\n attributes = {\n id = \"slot\" .. snapId,\n rotation = getSlotRotation(slotName),\n fontSize = \"145\",\n font = \"font_arkhamicons\",\n color = \"#414141CB\",\n text = slotNameToChar[slotName]\n }\n }\n }\n }\n table.insert(xml, slotXML)\n end\n end\n\n self.UI.setXmlTable(xml)\nend\n\n-- toggle the \"slot editing mode\"\nfunction toggleSlotEditing(_, clickedByColor, isRightClick)\n if isRightClick then\n resetSlotSymbols()\n return\n end\n\n updateMessageColor(clickedByColor)\n\n -- toggle internal variable\n currentlyEditingSlots = not currentlyEditingSlots\n\n if currentlyEditingSlots then\n editButtonLabel(\"Edit Slots\", \"Stop editing\")\n broadcastToColor(\"Click on a slot symbol (or an empty slot) to edit it.\", messageColor, \"Orange\")\n addClickFunctionToSlots()\n else\n editButtonLabel(\"Stop editing\", \"Edit Slots\")\n redrawSlotSymbols()\n end\nend\n\n-- click function for slot symbols during the \"slot editing mode\"\nfunction slotClickfunction(player, _, id)\n local slotIndex = id:gsub(\"slotPanel\", \"\")\n slotIndex = tonumber(slotIndex)\n\n -- make a list of the table keys as options for the dialog box\n local slotNames = {}\n for slotName, _ in pairs(slotNameToChar) do\n table.insert(slotNames, slotName)\n end\n\n -- prompt player to choose symbol\n player.showOptionsDialog(\"Choose Slot Symbol\", slotNames, slotData[slotIndex],\n function(chosenSlotName)\n slotData[slotIndex] = chosenSlotName\n\n -- update slot symbol\n self.UI.setAttribute(\"slot\" .. slotIndex, \"text\", slotNameToChar[chosenSlotName])\n\n -- update slot rotation\n self.UI.setAttribute(\"slot\" .. slotIndex, \"rotation\", getSlotRotation(chosenSlotName))\n end\n )\nend\n\n-- helper function to rotate the left hand\nfunction getSlotRotation(slotName)\n if slotName == \"Hand (left)\" then\n return \"0 180 180\"\n else\n return \"0 0 180\"\n end\nend\n\n-- reset the slot symbols by making a deep copy of the default data and redrawing\nfunction resetSlotSymbols()\n slotData = {}\n for _, slotName in ipairs(defaultSlotData) do\n table.insert(slotData, slotName)\n end\n\n redrawSlotSymbols()\n\n -- need to re-add the click functions if currently in edit mode\n if currentlyEditingSlots then\n addClickFunctionToSlots()\n end\nend\n\n-- enables the click functions for editing\nfunction addClickFunctionToSlots()\n for i = 1, #slotData do\n self.UI.setAttribute(\"slotPanel\" .. i, \"onClick\", \"slotClickfunction\")\n end\nend\n\n---------------------------------------------------------\n-- color related functions\n---------------------------------------------------------\n\n-- changes the player color\nfunction changeColor(clickedByColor)\n local colorList = Player.getColors()\n\n -- remove existing colors from the list of choices\n for _, existingColor in ipairs(Player.getAvailableColors()) do\n for i, newColor in ipairs(colorList) do\n if existingColor == newColor or newColor == \"Black\" or newColor == \"Grey\" then\n table.remove(colorList, i)\n end\n end\n end\n\n -- show the option dialog for color selection to the player that triggered this\n Player[clickedByColor].showOptionsDialog(\"Select a new color:\", colorList, _, function(color)\n -- update the color of the hand zone\n local handZone = ownedObjects.HandZone\n handZone.setValue(color)\n\n -- if the seated player clicked this, reseat him to the new color\n if clickedByColor == playerColor then\n navigationOverlayApi.copyVisibility(playerColor, color)\n Player[playerColor].changeColor(color)\n end\n\n -- update the internal variable\n playerColor = color\n end)\nend\n\n---------------------------------------------------------\n-- playmat token spawning\n---------------------------------------------------------\n\n-- Finds all customizable cards in this play area and updates their metadata based on the selections\n-- on the matching upgrade sheet.\n-- This method is theoretically O(n^2), and should be used sparingly. In practice it will only be\n-- called when a checkbox is added or removed in-game (which should be rare), and is bounded by the\n-- number of customizable cards in play.\nfunction syncAllCustomizableCards()\n for _, card in ipairs(searchAroundSelf(\"isCard\")) do\n syncCustomizableMetadata(card)\n end\nend\n\nfunction syncCustomizableMetadata(card)\n local cardMetadata = JSON.decode(card.getGMNotes()) or {}\n if cardMetadata == nil or cardMetadata.customizations == nil then return end\n\n for _, upgradeSheet in ipairs(searchAroundSelf(\"isCard\")) do\n local upgradeSheetMetadata = JSON.decode(upgradeSheet.getGMNotes()) or {}\n if upgradeSheetMetadata.id == (cardMetadata.id .. \"-c\") then\n for i, customization in ipairs(cardMetadata.customizations) do\n if customization.replaces ~= nil and customization.replaces.uses ~= nil then\n if upgradeSheet.call(\"isUpgradeActive\", i) then\n cardMetadata.uses = customization.replaces.uses\n card.setGMNotes(JSON.encode(cardMetadata))\n else\n -- TODO: Get the original metadata to restore it... maybe. This should only be\n -- necessary in the very unlikely case that a user un-checks a previously-full upgrade\n -- row while the card is in play. It will be much easier once the AllPlayerCardsApi is\n -- in place, so defer until it is\n end\n end\n end\n end\n end\nend\n\nfunction spawnTokensFor(object)\n local extraUses = {}\n if activeInvestigatorId == \"03004\" then\n extraUses[\"Charge\"] = 1\n end\n\n tokenManager.spawnForCard(object, extraUses)\nend\n\nfunction onCollisionEnter(collisionInfo)\n local object = collisionInfo.collision_object\n\n -- only continue if loading is completed\n if not collisionEnabled then return end\n\n -- only continue for cards\n if object.type ~= \"Card\" then return end\n\n -- detect if \"Dream-Enhancing Serum\" is placed\n if object.getName() == \"Dream-Enhancing Serum\" then isDES = true end\n\n maybeUpdateActiveInvestigator(object)\n syncCustomizableMetadata(object)\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n elseif shouldSpawnTokens(object) then\n spawnTokensFor(object)\n end\nend\n\n-- detect if \"Dream-Enhancing Serum\" is removed\nfunction onCollisionExit(collisionInfo)\n if collisionInfo.collision_object.getName() == \"Dream-Enhancing Serum\" then isDES = false end\nend\n\n-- checks if tokens should be spawned for the provided card\nfunction shouldSpawnTokens(card)\n if card.is_face_down then\n return false\n end\n\n local localCardPos = self.positionToLocal(card.getPosition())\n local metadata = JSON.decode(card.getGMNotes())\n\n -- If no metadata we don't know the type, so only spawn in the main area\n if metadata == nil then\n return inArea(localCardPos, MAIN_PLAY_AREA)\n end\n\n -- Spawn tokens for assets and events on the main area\n if inArea(localCardPos, MAIN_PLAY_AREA)\n and (metadata.type == \"Asset\"\n or metadata.type == \"Event\") then\n return true\n end\n\n -- Spawn tokens for all encounter types in the threat area\n if inArea(localCardPos, THREAT_AREA)\n and (metadata.type == \"Treachery\"\n or metadata.type == \"Enemy\"\n or metadata.weakness) then\n return true\n end\n\n return false\nend\n\nfunction onObjectEnterContainer(container, object)\n if object.type ~= \"Card\" then return end\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n end\nend\n\n-- removes tokens from the provided card/deck\nfunction removeTokensFromObject(object)\n if object.hasTag(\"CardThatSeals\") then\n local func = object.getVar(\"resetSealedTokens\") -- check if function exists (it won't for older custom content)\n if func ~= nil then\n object.call(\"resetSealedTokens\")\n end\n end\n\n for _, obj in ipairs(searchLib.onObject(object)) do\n if tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n elseif obj.getGUID() ~= \"4ee1f2\" and -- table\n obj ~= self and\n obj.type ~= \"Deck\" and\n obj.type ~= \"Card\" and\n obj.memo ~= nil and\n obj.getLock() == false and\n obj.getDescription() ~= \"Action Token\" then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n---------------------------------------------------------\n-- investigator ID grabbing and skill tracker\n---------------------------------------------------------\n\n-- updates the internal investigator id and action tokens if an investigator card is detected\n---@param card tts__Object Card that might be an investigator\nfunction maybeUpdateActiveInvestigator(card)\n if not inArea(self.positionToLocal(card.getPosition()), INVESTIGATOR_AREA) then return end\n\n local notes = JSON.decode(card.getGMNotes())\n local class\n\n if notes ~= nil and notes.type == \"Investigator\" and notes.id ~= nil then\n if notes.id == activeInvestigatorId then return end\n class = notes.class\n activeInvestigatorId = notes.id\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", {\n notes.willpowerIcons,\n notes.intellectIcons,\n notes.combatIcons,\n notes.agilityIcons\n })\n elseif activeInvestigatorId ~= \"00000\" then\n class = \"Neutral\"\n activeInvestigatorId = \"00000\"\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", { 1, 1, 1, 1 })\n else\n return\n end\n\n -- change state of action tokens\n local search = searchArea(self.positionToWorld({ -1.1, 0.05, -0.27 }), { 4, 1, 1 })\n local smallToken = nil\n local STATE_TABLE = {\n [\"Guardian\"] = 1,\n [\"Seeker\"] = 2,\n [\"Rogue\"] = 3,\n [\"Mystic\"] = 4,\n [\"Survivor\"] = 5,\n [\"Neutral\"] = 6\n }\n\n for _, obj in ipairs(search) do\n if obj.getDescription() == \"Action Token\" and obj.getStateId() \u003e 0 then\n if obj.getScale().x \u003c 0.4 then\n smallToken = obj\n else\n setObjectState(obj, STATE_TABLE[class])\n end\n end\n end\n\n -- update the small token with special action for certain investigators\n local SPECIAL_ACTIONS = {\n [\"04002\"] = 8, -- Ursula Downs\n [\"01002\"] = 9, -- Daisy Walker\n [\"01502\"] = 9, -- Daisy Walker\n [\"01002-pb\"] = 9, -- Daisy Walker\n [\"06003\"] = 10, -- Tony Morgan\n [\"04003\"] = 11, -- Finn Edwards\n [\"08016\"] = 14 -- Bob Jenkins\n }\n\n if smallToken ~= nil then\n setObjectState(smallToken, SPECIAL_ACTIONS[activeInvestigatorId] or STATE_TABLE[class])\n end\nend\n\nfunction setObjectState(obj, stateId)\n if obj.getStateId() ~= stateId then obj.setState(stateId) end\nend\n\n---------------------------------------------------------\n-- manipulation of owned objects\n---------------------------------------------------------\n\n-- updates the specified owned counter\n---@param param table Contains the information to update:\n--- type: String Counter to target\n--- newValue: Number Value to set the counter to\n--- modifier: Number If newValue is not provided, the existing value will be adjusted by this modifier\nfunction updateCounter(param)\n local counter = ownedObjects[param.type]\n if counter ~= nil then\n counter.call(\"updateVal\", param.newValue or (counter.getVar(\"val\") + param.modifier))\n else\n printToAll(param.type .. \" for \" .. matColor .. \" could not be found.\", \"Yellow\")\n end\nend\n\n-- get the value the specified owned counter\n---@param type string Counter to target\n---@return number: Counter value\nfunction getCounterValue(type)\n return ownedObjects[type].getVar(\"val\")\nend\n\n-- set investigator skill tracker to \"1, 1, 1, 1\"\nfunction resetSkillTracker()\n local obj = ownedObjects.InvestigatorSkillTracker\n if obj ~= nil then\n obj.call(\"updateStats\", { 1, 1, 1, 1 })\n else\n printToAll(\"Skill tracker for \" .. matColor .. \" playmat could not be found.\", \"Yellow\")\n end\nend\n\n---------------------------------------------------------\n-- calls to 'Global' / functions for calls from outside\n---------------------------------------------------------\n\nfunction drawChaosTokenButton(_, _, isRightClick)\n chaosBagApi.drawChaosToken(self, isRightClick)\nend\n\nfunction drawEncounterCard(_, _, isRightClick)\n local drawPos = getEncounterCardDrawPosition(not isRightClick)\n mythosAreaApi.drawEncounterCard(matColor, drawPos)\nend\n\nfunction returnGlobalDiscardPosition()\n return self.positionToWorld(DISCARD_PILE_POSITION)\nend\n\nfunction returnGlobalDrawPosition()\n return self.positionToWorld(DRAW_DECK_POSITION)\nend\n\n-- returns the position for encounter card drawing\n---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\nfunction getEncounterCardDrawPosition(stack)\n local drawPos = self.positionToWorld(DRAWN_ENCOUNTER_POSITION)\n\n -- maybe override position with first empty slot in threat area (right to left)\n if not stack then\n local searchPos = Vector(-0.91, 0.5, -0.625)\n for i = 1, 5 do\n local globalSearchPos = self.positionToWorld(searchPos)\n local searchResult = searchLib.atPosition(globalSearchPos, \"isCardOrDeck\")\n if #searchResult == 0 then\n drawPos = globalSearchPos\n break\n else\n searchPos.x = searchPos.x + 0.455\n end\n end\n end\n\n return drawPos\nend\n\n-- creates / removes the draw 1 button\n---@param visible boolean Whether the draw 1 button should be visible\nfunction showDrawButton(visible)\n isDrawButtonVisible = visible\n\n if isDrawButtonVisible then\n -- Draw 1 button: modified default data\n buttonParameters.label = \"Draw 1\"\n buttonParameters.click_function = \"doDrawOne\"\n buttonParameters.tooltip = \"\"\n buttonParameters.position.z = -0.35\n self.createButton(buttonParameters)\n else\n local buttons = self.getButtons()\n for i = 1, #buttons do\n if buttons[i].label == \"Draw 1\" then\n self.removeButton(buttons[i].index)\n end\n end\n end\nend\n\n-- shows / hides a clickable clue counter for this playmat and sets the correct amount of clues\n---@param showCounter boolean Whether the clickable clue counter should be visible\nfunction clickableClues(showCounter)\n local clickerPos = ownedObjects.ClickableClueCounter.getPosition()\n local clueCount = 0\n\n -- move clue counters\n local modY = showCounter and 0.525 or -0.525\n ownedObjects.ClickableClueCounter.setPosition(clickerPos + Vector(0, modY, 0))\n\n if showCounter then\n -- get current clue count\n clueCount = ownedObjects.ClueCounter.getVar(\"exposedValue\")\n\n -- remove clues\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n\n -- set value for clue clickers\n ownedObjects.ClickableClueCounter.call(\"updateVal\", clueCount)\n else\n -- get current clue count\n clueCount = ownedObjects.ClickableClueCounter.getVar(\"val\")\n\n -- spawn clues\n local pos = self.positionToWorld({ x = -1.12, y = 0.05, z = 0.7 })\n for i = 1, clueCount do\n pos.y = pos.y + 0.045 * i\n tokenManager.spawnToken(pos, \"clue\", self.getRotation())\n end\n end\nend\n\n-- removes all clues (moving tokens to the trash and setting counters to 0)\nfunction removeClues()\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n ownedObjects.ClickableClueCounter.call(\"updateVal\", 0)\nend\n\n-- reports the clue count\n---@param useClickableCounters boolean Controls which type of counter is getting checked\nfunction getClueCount(useClickableCounters)\n if useClickableCounters then\n return ownedObjects.ClickableClueCounter.getVar(\"val\")\n else\n return ownedObjects.ClueCounter.getVar(\"exposedValue\")\n end\nend\n\n-- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes\n-- is true, the main card slot snap points will only snap assets, while the investigator area point\n-- will only snap Investigators. If matchTypes is false, snap points will be reset to snap all cards.\n---@param matchTypes boolean Whether snap points should only snap for the matching card types.\nfunction setLimitSnapsByType(matchTypes)\n local snaps = self.getSnapPoints()\n for i, snap in ipairs(snaps) do\n if inArea(snap.position, MAIN_PLAY_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Asset\" }\n else\n table.insert(snaps[i].tags, \"Asset\")\n end\n else\n snaps[i].tags = nil\n end\n end\n if inArea(snap.position, INVESTIGATOR_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Investigator\" }\n else\n table.insert(snaps[i].tags, \"Investigator\")\n end\n else\n snaps[i].tags = nil\n end\n end\n end\n self.setSnapPoints(snaps)\nend\n\n-- Simple method to check if the given point is in a specified area. Local use only\n---@param point tts__Vector Point to check, only x and z values are relevant\n---@param bounds table Defined area to see if the point is within. See MAIN_PLAY_AREA for sample bounds definition.\n---@return boolean: True if the point is in the area defined by bounds\nfunction inArea(point, bounds)\n return (point.x \u003c bounds.upperLeft.x\n and point.x \u003e bounds.lowerRight.x\n and point.z \u003c bounds.upperLeft.z\n and point.z \u003e bounds.lowerRight.z)\nend\n\n-- called by custom data helpers to add player card data\n---@param args table Contains only one entry, the GUID of the custom data helper\nfunction updatePlayerCards(args)\n local customDataHelper = getObjectFromGUID(args[1])\n local playerCardData = customDataHelper.getTable(\"PLAYER_CARD_DATA\")\n tokenManager.addPlayerCardData(playerCardData)\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/NavigationOverlayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local NavigationOverlayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getNOHandler()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"NavigationOverlayHandler\")\n end\n\n -- copies the visibility for the Navigation overlay\n ---@param startColor string Color of the player to copy from\n ---@param targetColor string Color of the targeted player\n NavigationOverlayApi.copyVisibility = function(startColor, targetColor)\n getNOHandler().call(\"copyVisibility\", {\n startColor = startColor,\n targetColor = targetColor\n })\n end\n\n -- changes the Navigation Overlay view (\"Full View\" --\u003e \"Play Areas\" --\u003e \"Closed\" etc.)\n ---@param playerColor string Color of the player to update the visibility for\n NavigationOverlayApi.cycleVisibility = function(playerColor)\n getNOHandler().call(\"cycleVisibility\", playerColor)\n end\n\n -- loads the specified camera for a player\n ---@param player tts__Player Player whose camera should be moved\n ---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to\n NavigationOverlayApi.loadCamera = function(player, camera)\n getNOHandler().call(\"loadCameraFromApi\", {\n player = player,\n camera = camera\n })\n end\n\n return NavigationOverlayApi\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot? table New rotation for the object\n ---@param below? boolean Should the object be placed below an existing deck?\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot, below)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local offset = 0.5\n local newPos = Vector(pos) + Vector(0, offset, 0)\n\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n if below then\n newPos = Vector(pos):setAt(\"y\", bounds.center.y - bounds.size.y / 2)\n else\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n end\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScriptState": "{\"activeInvestigatorId\":\"00000\",\"isDrawButtonVisible\":false,\"playerColor\":\"Green\",\"slotData\":[\"any\",\"any\",\"any\",\"Tarot\",\"Hand (left)\",\"Hand (right)\",\"Ally\",\"any\",\"any\",\"any\",\"Accessory\",\"Arcane\",\"Arcane\",\"Body\"]}", "MeasureMovement": false, "Memo": "Green", "Name": "Custom_Tile", @@ -51473,9 +51483,9 @@ }, { "Position": { - "x": -0.631, + "x": 1.758, "y": 0.1, - "z": 0.551 + "z": 0.04 }, "Tags": [ "Asset" @@ -51483,39 +51493,9 @@ }, { "Position": { - "x": -0.616, - "y": 0.102, - "z": 0.024 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": -0.177, - "y": 0.101, - "z": 0.032 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": -0.174, - "y": 0.099, - "z": 0.551 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": 0.212, + "x": 1.371, "y": 0.1, - "z": 0.559 + "z": 0.038 }, "Tags": [ "Asset" @@ -51523,7 +51503,7 @@ }, { "Position": { - "x": 0.217, + "x": 0.98, "y": 0.1, "z": 0.035 }, @@ -51543,28 +51523,8 @@ }, { "Position": { - "x": 0.605, + "x": 0.217, "y": 0.1, - "z": 0.555 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": 0.977, - "y": 0.099, - "z": 0.556 - }, - "Tags": [ - "Asset" - ] - }, - { - "Position": { - "x": 0.98, - "y": 0.099, "z": 0.035 }, "Tags": [ @@ -51573,9 +51533,9 @@ }, { "Position": { - "x": 1.371, + "x": -0.177, "y": 0.1, - "z": 0.038 + "z": 0.032 }, "Tags": [ "Asset" @@ -51583,9 +51543,9 @@ }, { "Position": { - "x": 1.371, - "y": 0.099, - "z": 0.558 + "x": -0.616, + "y": 0.1, + "z": 0.024 }, "Tags": [ "Asset" @@ -51603,9 +51563,59 @@ }, { "Position": { - "x": 1.758, - "y": 0.101, - "z": 0.04 + "x": 1.371, + "y": 0.1, + "z": 0.558 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": 0.977, + "y": 0.1, + "z": 0.556 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": 0.605, + "y": 0.1, + "z": 0.555 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": 0.212, + "y": 0.1, + "z": 0.559 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": -0.174, + "y": 0.1, + "z": 0.551 + }, + "Tags": [ + "Asset" + ] + }, + { + "Position": { + "x": -0.631, + "y": 0.1, + "z": 0.551 }, "Tags": [ "Asset" @@ -51745,7 +51755,7 @@ }, "ImageScalar": 1, "ImageSecondaryURL": "", - "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037357630681963618/E7271737B19CE0BFAAA382BEEEF497FE3E06ECC1/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/", "WidthScale": 0 }, "Description": "", @@ -51759,8 +51769,8 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/Playmat\")\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat\n ---@param mat tts__Object Playermat that triggered this\n ---@param alwaysFaceUp boolean Whether the card should be drawn face-up\n MythosAreaApi.drawEncounterCard = function(mat, alwaysFaceUp)\n getMythosArea().call(\"drawEncounterCard\", {mat = mat, alwaysFaceUp = alwaysFaceUp})\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"core/NavigationOverlayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local NavigationOverlayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getNOHandler()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"NavigationOverlayHandler\")\n end\n\n -- copies the visibility for the Navigation overlay\n ---@param startColor string Color of the player to copy from\n ---@param targetColor string Color of the targeted player\n NavigationOverlayApi.copyVisibility = function(startColor, targetColor)\n getNOHandler().call(\"copyVisibility\", {\n startColor = startColor,\n targetColor = targetColor\n })\n end\n\n -- changes the Navigation Overlay view (\"Full View\" --\u003e \"Play Areas\" --\u003e \"Closed\" etc.)\n ---@param playerColor string Color of the player to update the visibility for\n NavigationOverlayApi.cycleVisibility = function(playerColor)\n getNOHandler().call(\"cycleVisibility\", playerColor)\n end\n\n -- loads the specified camera for a player\n ---@param player tts__Player Player whose camera should be moved\n ---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to\n NavigationOverlayApi.loadCamera = function(player, camera)\n getNOHandler().call(\"loadCameraFromApi\", {\n player = player,\n camera = camera\n })\n end\n\n return NavigationOverlayApi\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/token/TokenChecker\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local CHAOS_TOKEN_NAMES = {\n [\"Elder Sign\"] = true,\n [\"+1\"] = true,\n [\"0\"] = true,\n [\"-1\"] = true,\n [\"-2\"] = true,\n [\"-3\"] = true,\n [\"-4\"] = true,\n [\"-5\"] = true,\n [\"-6\"] = true,\n [\"-7\"] = true,\n [\"-8\"] = true,\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n [\"Auto-fail\"] = true,\n [\"Bless\"] = true,\n [\"Curse\"] = true,\n [\"Frost\"] = true\n }\n\n local TokenChecker = {}\n\n -- returns true if the passed object is a chaos token (by name)\n TokenChecker.isChaosToken = function(obj)\n if obj.type == \"Tile\" and CHAOS_TOKEN_NAMES[obj.getName()] then\n return true\n else\n return false\n end\n end\n\n return TokenChecker\nend\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror\n -- tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned) spawned.setState(tokenValue) end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"playermat/Playmat\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal deckLib = require(\"util/DeckLib\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal navigationOverlayApi = require(\"core/NavigationOverlayApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenChecker = require(\"core/token/TokenChecker\")\nlocal tokenManager = require(\"core/token/TokenManager\")\n\n-- we use this to turn off collision handling until onLoad() is complete\nlocal collisionEnabled = false\n\n-- x-Values for discard buttons\nlocal DISCARD_BUTTON_OFFSETS = {-1.365, -0.91, -0.455, 0, 0.455, 0.91}\n\nlocal SEARCH_AROUND_SELF_X_BUFFER = 8\n\n-- defined areas for object searching\nlocal MAIN_PLAY_AREA = {\n upperLeft = {\n x = 1.98,\n z = 0.736\n },\n lowerRight = {\n x = -0.79,\n z = -0.39\n }\n}\nlocal INVESTIGATOR_AREA = {\n upperLeft = {\n x = -1.084,\n z = 0.06517\n },\n lowerRight = {\n x = -1.258,\n z = -0.0805\n }\n}\nlocal THREAT_AREA = {\n upperLeft = {\n x = 1.53,\n z = -0.34\n },\n lowerRight = {\n x = -1.13,\n z = -0.92\n }\n}\nlocal DECK_DISCARD_AREA = {\n upperLeft = {\n x = -1.62,\n z = 0.855\n },\n lowerRight = {\n x = -2.02,\n z = -0.245\n },\n center = {\n x = -1.82,\n y = 0.5,\n z = 0.305\n },\n size = {\n x = 0.4,\n y = 3,\n z = 1.1\n }\n}\n\n-- local position of draw and discard pile\nlocal DRAW_DECK_POSITION = { x = -1.82, y = 0.1, z = 0 }\nlocal DISCARD_PILE_POSITION = { x = -1.82, y = 0.1, z = 0.61 }\n\n-- global position of encounter discard pile\nlocal ENCOUNTER_DISCARD_POSITION = { x = -3.85, y = 1.5, z = 10.38}\n\n-- global variable so it can be reset by the Clean Up Helper\nactiveInvestigatorId = \"00000\"\n\n-- table of type-object reference pairs of all owned objects\nlocal ownedObjects = {}\nlocal matColor = self.getMemo()\n\n-- variable to track the status of the \"Show Draw Button\" option\nlocal isDrawButtonVisible = false\n\n-- global variable to report \"Dream-Enhancing Serum\" status\nisDES = false\n\nfunction onSave()\n return JSON.encode({\n playerColor = playerColor,\n activeInvestigatorId = activeInvestigatorId,\n isDrawButtonVisible = isDrawButtonVisible\n })\nend\n\nfunction onLoad(saveState)\n self.interactable = false\n\n -- get object references to owned objects\n ownedObjects = guidReferenceApi.getObjectsByOwner(matColor)\n\n -- button creation\n for i = 1, 6 do\n makeDiscardButton(DISCARD_BUTTON_OFFSETS[i], i)\n end\n\n self.createButton({\n click_function = \"drawEncounterCard\",\n function_owner = self,\n position = {-1.84, 0, -0.65},\n rotation = {0, 80, 0},\n width = 265,\n height = 190\n })\n\n self.createButton({\n click_function = \"drawChaosTokenButton\",\n function_owner = self,\n position = {1.85, 0, -0.74},\n rotation = {0, -45, 0},\n width = 135,\n height = 135\n })\n\n self.createButton({\n label = \"Upkeep\",\n click_function = \"doUpkeep\",\n function_owner = self,\n position = {1.84, 0.1, -0.44},\n scale = {0.12, 0.12, 0.12},\n width = 800,\n height = 280,\n font_size = 180\n })\n\n -- save state loading\n local state = JSON.decode(saveState)\n if state ~= nil then\n playerColor = state.playerColor\n activeInvestigatorId = state.activeInvestigatorId\n isDrawButtonVisible = state.isDrawButtonVisible\n end\n\n showDrawButton(isDrawButtonVisible)\n math.randomseed(os.time())\n Wait.time(function() collisionEnabled = true end, 0.1)\nend\n\n---------------------------------------------------------\n-- utility functions\n---------------------------------------------------------\n\n-- searches an area and optionally filters the result\nfunction searchArea(origin, size, filter)\n return searchLib.inArea(origin, self.getRotation(), size, filter)\nend\n\n-- finds all objects on the playmat and associated set aside zone.\nfunction searchAroundSelf(filter)\n local bounds = self.getBoundsNormalized()\n -- Increase the width to cover the set aside zone\n bounds.size.x = bounds.size.x + SEARCH_AROUND_SELF_X_BUFFER\n bounds.size.y = 1\n -- Since the cast is centered on the position, shift left or right to keep the non-set aside edge\n -- of the cast at the edge of the playmat\n -- setAsideDirection accounts for the set aside zone being on the left or right, depending on the\n -- table position of the playmat\n local setAsideDirection = bounds.center.z \u003e 0 and 1 or -1\n local localCenter = self.positionToLocal(bounds.center)\n localCenter.x = localCenter.x + setAsideDirection * SEARCH_AROUND_SELF_X_BUFFER / 2 / self.getScale().x\n return searchArea(self.positionToWorld(localCenter), bounds.size, filter)\nend\n\n-- searches the area around the draw deck and discard pile\nfunction searchDeckAndDiscardArea(filter)\n local pos = self.positionToWorld(DECK_DISCARD_AREA.center)\n local scale = self.getScale()\n local size = {\n x = DECK_DISCARD_AREA.size.x * scale.x,\n y = DECK_DISCARD_AREA.size.y, \n z = DECK_DISCARD_AREA.size.z * scale.z\n }\n return searchArea(pos, size, filter)\nend\n\nfunction doNotReady(card)\n return card.getVar(\"do_not_ready\") or false\nend\n\n-- rounds a number to the specified amount of decimal places\n---@param num number Initial value\n---@param numDecimalPlaces number Amount of decimal places\nfunction round(num, numDecimalPlaces)\n local mult = 10^(numDecimalPlaces or 0)\n return math.floor(num * mult + 0.5) / mult\nend\n\n---------------------------------------------------------\n-- Discard buttons\n---------------------------------------------------------\n\n-- handles discarding for a list of objects\n---@param objList table List of objects to discard\nfunction discardListOfObjects(objList)\n for _, obj in ipairs(objList) do\n if obj.type == \"Card\" or obj.type == \"Deck\" then\n if obj.hasTag(\"PlayerCard\") then\n deckLib.placeOrMergeIntoDeck(obj, returnGlobalDiscardPosition(), self.getRotation())\n else\n deckLib.placeOrMergeIntoDeck(obj, ENCOUNTER_DISCARD_POSITION, {x = 0, y = -90, z = 0})\n end\n -- put chaos tokens back into bag (e.g. Unrelenting)\n elseif tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n -- don't touch locked objects (like the table etc.)\n elseif not obj.getLock() then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n-- build a discard button to discard from searchPosition (number must be unique)\nfunction makeDiscardButton(xValue, number)\n local position = { xValue, 0.1, -0.94}\n local searchPosition = {-position[1], position[2], position[3] + 0.32}\n local handlerName = 'handler' .. number\n self.setVar(handlerName, function()\n local cardSizeSearch = {2, 1, 3.2}\n local globalSearchPosition = self.positionToWorld(searchPosition)\n local searchResult = searchArea(globalSearchPosition, cardSizeSearch)\n return discardListOfObjects(searchResult)\n end)\n self.createButton({\n label = \"Discard\",\n click_function = handlerName,\n function_owner = self,\n position = position,\n scale = {0.12, 0.12, 0.12},\n width = 900,\n height = 350,\n font_size = 220\n })\nend\n\n---------------------------------------------------------\n-- Upkeep button\n---------------------------------------------------------\n\n-- calls the Upkeep function with correct parameter\nfunction doUpkeepFromHotkey(color)\n doUpkeep(_, color)\nend\n\nfunction doUpkeep(_, clickedByColor, isRightClick)\n if isRightClick then\n changeColor(clickedByColor)\n return\n end\n\n -- send messages to player who clicked button if no seated player found\n messageColor = Player[playerColor].seated and playerColor or clickedByColor\n\n -- unexhaust cards in play zone, flip action tokens and find forcedLearning\n local forcedLearning = false\n local rot = self.getRotation()\n for _, obj in ipairs(searchAroundSelf()) do\n if obj.getDescription() == \"Action Token\" and obj.is_face_down then\n obj.flip()\n elseif obj.type == \"Card\" and not inArea(self.positionToLocal(obj.getPosition()), INVESTIGATOR_AREA) then\n local cardMetadata = JSON.decode(obj.getGMNotes()) or {}\n if not doNotReady(obj) then\n local cardRotation = round(obj.getRotation().y, 0) - rot.y\n local yRotDiff = 0\n\n if cardRotation \u003c 0 then\n cardRotation = cardRotation + 360\n end\n\n -- rotate cards to the next multiple of 90° towards 0°\n if cardRotation \u003e 90 and cardRotation \u003c= 180 then\n yRotDiff = 90\n elseif cardRotation \u003c 270 and cardRotation \u003e 180 then\n yRotDiff = 270\n end\n\n -- set correct rotation for face-down cards\n rot.z = obj.is_face_down and 180 or 0\n obj.setRotation({rot.x, rot.y + yRotDiff, rot.z})\n end\n if cardMetadata.id == \"08031\" then\n forcedLearning = true\n end\n if cardMetadata.uses ~= nil then\n tokenManager.maybeReplenishCard(obj, cardMetadata.uses, self)\n end\n end\n end\n\n -- flip investigator mini-card and summoned servitor mini-card\n -- (all characters allowed to account for custom IDs - e.g. 'Z0000' for TTS Zoop generated IDs)\n local miniId = string.match(activeInvestigatorId, \".....\") .. \"-m\"\n for _, obj in ipairs(getObjects()) do\n if obj.type == \"Card\" and obj.is_face_down then\n local notes = JSON.decode(obj.getGMNotes())\n if notes ~= nil and notes.type == \"Minicard\" and (notes.id == miniId or notes.id == \"09080-m\") then\n obj.flip()\n end\n end\n end\n\n -- gain a resource (or two if playing Jenny Barnes)\n if string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"02003\" then\n updateCounter({type = \"ResourceCounter\", modifier = 2})\n printToColor(\"Gaining 2 resources (Jenny)\", messageColor)\n else\n updateCounter({type = \"ResourceCounter\", modifier = 1})\n end\n\n -- draw a card (with handling for Patrice and Forced Learning)\n if activeInvestigatorId == \"06005\" then\n if forcedLearning then\n printToColor(\"Wow, did you really take 'Versatile' to play Patrice with 'Forced Learning'? Choose which draw replacement effect takes priority and draw cards accordingly.\", messageColor)\n else\n local handSize = #Player[playerColor].getHandObjects()\n if handSize \u003c 5 then\n local cardsToDraw = 5 - handSize\n printToColor(\"Drawing \" .. cardsToDraw .. \" cards (Patrice)\", messageColor)\n drawCardsWithReshuffle(cardsToDraw)\n end\n end\n elseif forcedLearning then\n printToColor(\"Drawing 2 cards, discard 1 (Forced Learning)\", messageColor)\n drawCardsWithReshuffle(2)\n elseif activeInvestigatorId == \"89001\" then\n printToColor(\"Drawing 2 cards (Subject 5U-21)\", messageColor)\n drawCardsWithReshuffle(2)\n else\n drawCardsWithReshuffle(1)\n end\nend\n\n-- function for \"draw 1 button\" (that can be added via option panel)\nfunction doDrawOne(_, color)\n -- send messages to player who clicked button if no seated player found\n messageColor = Player[playerColor].seated and playerColor or color\n drawCardsWithReshuffle(1)\nend\n\n-- draw X cards (shuffle discards if necessary)\nfunction drawCardsWithReshuffle(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n\n -- Norman Withers handling\n local harbinger = false\n if deckAreaObjects.topCard and deckAreaObjects.topCard.getName() == \"The Harbinger\" then\n harbinger = true\n elseif deckAreaObjects.draw and not deckAreaObjects.draw.is_face_down then\n local cards = deckAreaObjects.draw.getObjects()\n if cards[#cards].name == \"The Harbinger\" then\n harbinger = true\n end\n end\n\n if harbinger then\n printToColor(\"The Harbinger is on top of your deck, not drawing cards\", messageColor)\n return\n end\n\n local topCardDetected = false\n if deckAreaObjects.topCard ~= nil then\n deckAreaObjects.topCard.deal(1, playerColor)\n topCardDetected = true\n numCards = numCards - 1\n if numCards == 0 then\n flipTopCardFromDeck()\n return\n end\n end\n\n local deckSize = 1\n if deckAreaObjects.draw == nil then\n deckSize = 0\n elseif deckAreaObjects.draw.type == \"Deck\" then\n deckSize = #deckAreaObjects.draw.getObjects()\n end\n\n if deckSize \u003e= numCards then\n drawCards(numCards)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n else\n drawCards(deckSize)\n if deckAreaObjects.discard ~= nil then\n shuffleDiscardIntoDeck()\n Wait.time(function()\n drawCards(numCards - deckSize)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n end, 1)\n end\n printToColor(\"Take 1 horror (drawing card from empty deck)\", messageColor)\n end\nend\n\n-- get the draw deck and discard pile objects and returns the references\nfunction getDeckAreaObjects()\n local deckAreaObjects = {}\n for _, object in ipairs(searchDeckAndDiscardArea(\"isCardOrDeck\")) do\n if self.positionToLocal(object.getPosition()).z \u003e 0.5 then\n deckAreaObjects.discard = object\n -- Norman Withers handling\n elseif object.type == \"Card\" and not object.is_face_down then\n deckAreaObjects.topCard = object\n else\n deckAreaObjects.draw = object\n end\n end\n return deckAreaObjects\nend\n\nfunction drawCards(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.draw then\n deckAreaObjects.draw.deal(numCards, playerColor)\n end\nend\n\nfunction shuffleDiscardIntoDeck()\n local deckAreaObjects = getDeckAreaObjects()\n if not deckAreaObjects.discard.is_face_down then\n deckAreaObjects.discard.flip()\n end\n deckAreaObjects.discard.shuffle()\n deckAreaObjects.discard.setPositionSmooth(self.positionToWorld(DRAW_DECK_POSITION), false, false)\nend\n\n-- utility function for Norman Withers to flip the top card to the revealed side\nfunction flipTopCardFromDeck()\n Wait.time(function()\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.topCard then\n elseif deckAreaObjects.draw then\n if deckAreaObjects.draw.type == \"Card\" then\n deckAreaObjects.draw.flip()\n else\n -- get bounds to know the height of the deck\n local bounds = deckAreaObjects.draw.getBounds()\n local pos = bounds.center + Vector(0, bounds.size.y / 2 + 0.2, 0)\n deckAreaObjects.draw.takeObject({ position = pos, flip = true })\n end\n end\n end, 0.1)\nend\n\n-- discard a random non-hidden card from hand\nfunction doDiscardOne()\n local hand = Player[playerColor].getHandObjects()\n if #hand == 0 then\n broadcastToAll(\"Cannot discard from empty hand!\", \"Red\")\n else\n local choices = {}\n for i = 1, #hand do\n local notes = JSON.decode(hand[i].getGMNotes())\n if notes ~= nil then\n if notes.hidden ~= true then\n table.insert(choices, i)\n end\n else\n table.insert(choices, i)\n end\n end\n\n if #choices == 0 then\n broadcastToAll(\"Hidden cards can't be randomly discarded.\", \"Orange\")\n return\n end\n\n -- get a random non-hidden card (from the \"choices\" table)\n local num = math.random(1, #choices)\n deckLib.placeOrMergeIntoDeck(hand[choices[num]], returnGlobalDiscardPosition(), self.getRotation())\n\n local playerName = Player[playerColor].steam_name or playerColor\n broadcastToAll(playerName .. \" randomly discarded card \" .. choices[num] .. \"/\" .. #hand .. \".\", \"White\")\n end\nend\n\n---------------------------------------------------------\n-- color related functions\n---------------------------------------------------------\n\n-- changes the player color\nfunction changeColor(clickedByColor)\n local colorList = {\n \"White\",\n \"Brown\",\n \"Red\",\n \"Orange\",\n \"Yellow\",\n \"Green\",\n \"Teal\",\n \"Blue\",\n \"Purple\",\n \"Pink\"\n }\n\n -- remove existing colors from the list of choices\n for _, existingColor in ipairs(Player.getAvailableColors()) do\n for i, newColor in ipairs(colorList) do\n if existingColor == newColor then\n table.remove(colorList, i)\n end\n end\n end\n\n -- show the option dialog for color selection to the player that triggered this\n Player[clickedByColor].showOptionsDialog(\"Select a new color:\", colorList, _, function(color)\n -- update the color of the hand zone\n local handZone = ownedObjects.HandZone\n handZone.setValue(color)\n\n -- if the seated player clicked this, reseat him to the new color\n if clickedByColor == playerColor then\n navigationOverlayApi.copyVisibility(playerColor, color)\n Player[playerColor].changeColor(color)\n end\n\n -- update the internal variable\n playerColor = color\n end)\nend\n\n---------------------------------------------------------\n-- playmat token spawning\n---------------------------------------------------------\n\n-- Finds all customizable cards in this play area and updates their metadata based on the selections\n-- on the matching upgrade sheet.\n-- This method is theoretically O(n^2), and should be used sparingly. In practice it will only be\n-- called when a checkbox is added or removed in-game (which should be rare), and is bounded by the\n-- number of customizable cards in play.\nfunction syncAllCustomizableCards()\n for _, card in ipairs(searchAroundSelf(\"isCard\")) do\n syncCustomizableMetadata(card)\n end\nend\n\nfunction syncCustomizableMetadata(card)\n local cardMetadata = JSON.decode(card.getGMNotes()) or { }\n if cardMetadata == nil or cardMetadata.customizations == nil then\n return\n end\n for _, upgradeSheet in ipairs(searchAroundSelf(\"isCard\")) do\n local upgradeSheetMetadata = JSON.decode(upgradeSheet.getGMNotes()) or { }\n if upgradeSheetMetadata.id == (cardMetadata.id .. \"-c\") then\n for i, customization in ipairs(cardMetadata.customizations) do\n if customization.replaces ~= nil and customization.replaces.uses ~= nil then\n -- Allowed use of call(), no APIs for individual cards\n if upgradeSheet.call(\"isUpgradeActive\", i) then\n cardMetadata.uses = customization.replaces.uses\n card.setGMNotes(JSON.encode(cardMetadata))\n else\n -- TODO: Get the original metadata to restore it... maybe. This should only be\n -- necessary in the very unlikely case that a user un-checks a previously-full upgrade\n -- row while the card is in play. It will be much easier once the AllPlayerCardsApi is\n -- in place, so defer until it is\n end\n end\n end\n end\n end\nend\n\nfunction spawnTokensFor(object)\n local extraUses = { }\n if activeInvestigatorId == \"03004\" then\n extraUses[\"Charge\"] = 1\n end\n\n tokenManager.spawnForCard(object, extraUses)\nend\n\nfunction onCollisionEnter(collisionInfo)\n local object = collisionInfo.collision_object\n\n -- only continue if loading is completed\n if not collisionEnabled then return end\n\n -- only continue for cards\n if object.type ~= \"Card\" then return end\n\n -- detect if \"Dream-Enhancing Serum\" is placed\n if object.getName() == \"Dream-Enhancing Serum\" then isDES = true end\n\n maybeUpdateActiveInvestigator(object)\n syncCustomizableMetadata(object)\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n elseif shouldSpawnTokens(object) then\n spawnTokensFor(object)\n end\nend\n\n-- detect if \"Dream-Enhancing Serum\" is removed\nfunction onCollisionExit(collisionInfo)\n if collisionInfo.collision_object.getName() == \"Dream-Enhancing Serum\" then isDES = false end\nend\n\n-- checks if tokens should be spawned for the provided card\nfunction shouldSpawnTokens(card)\n if card.is_face_down then\n return false\n end\n\n local localCardPos = self.positionToLocal(card.getPosition())\n local metadata = JSON.decode(card.getGMNotes())\n\n -- If no metadata we don't know the type, so only spawn in the main area\n if metadata == nil then\n return inArea(localCardPos, MAIN_PLAY_AREA)\n end\n\n -- Spawn tokens for assets and events on the main area\n if inArea(localCardPos, MAIN_PLAY_AREA)\n and (metadata.type == \"Asset\"\n or metadata.type == \"Event\") then\n return true\n end\n\n -- Spawn tokens for all encounter types in the threat area\n if inArea(localCardPos, THREAT_AREA)\n and (metadata.type == \"Treachery\"\n or metadata.type == \"Enemy\"\n or metadata.weakness) then\n return true\n end\n\n return false\nend\n\nfunction onObjectEnterContainer(container, object)\n if object.type ~= \"Card\" then return end\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n end\nend\n\n-- removes tokens from the provided card/deck\nfunction removeTokensFromObject(object)\n if object.hasTag(\"CardThatSeals\") then\n local func = object.getVar(\"resetSealedTokens\") -- check if function exists (it won't for older custom content)\n if func ~= nil then\n object.call(\"resetSealedTokens\")\n end\n end\n\n for _, obj in ipairs(searchLib.onObject(object)) do\n if tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n elseif obj.getGUID() ~= \"4ee1f2\" and -- table\n obj ~= self and\n obj.type ~= \"Deck\" and\n obj.type ~= \"Card\" and\n obj.memo ~= nil and\n obj.getLock() == false and\n obj.getDescription() ~= \"Action Token\" then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n---------------------------------------------------------\n-- investigator ID grabbing and skill tracker\n---------------------------------------------------------\n\nfunction maybeUpdateActiveInvestigator(card)\n if not inArea(self.positionToLocal(card.getPosition()), INVESTIGATOR_AREA) then return end\n\n local notes = JSON.decode(card.getGMNotes())\n local class\n\n if notes ~= nil and notes.type == \"Investigator\" and notes.id ~= nil then\n if notes.id == activeInvestigatorId then return end\n class = notes.class\n activeInvestigatorId = notes.id\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", {\n notes.willpowerIcons,\n notes.intellectIcons,\n notes.combatIcons,\n notes.agilityIcons\n })\n elseif activeInvestigatorId ~= \"00000\" then\n class = \"Neutral\"\n activeInvestigatorId = \"00000\"\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", {1, 1, 1, 1})\n else\n return\n end\n\n -- change state of action tokens\n local search = searchArea(self.positionToWorld({-1.1, 0.05, -0.27}), {4, 1, 1})\n local smallToken = nil\n local STATE_TABLE = {\n [\"Guardian\"] = 1,\n [\"Seeker\"] = 2,\n [\"Rogue\"] = 3,\n [\"Mystic\"] = 4,\n [\"Survivor\"] = 5,\n [\"Neutral\"] = 6\n }\n\n for _, obj in ipairs(search) do\n if obj.getDescription() == \"Action Token\" and obj.getStateId() \u003e 0 then\n if obj.getScale().x \u003c 0.4 then\n smallToken = obj\n else\n setObjectState(obj, STATE_TABLE[class])\n end\n end\n end\n\n -- update the small token with special action for certain investigators\n local SPECIAL_ACTIONS = {\n [\"04002\"] = 8, -- Ursula Downs\n [\"01002\"] = 9, -- Daisy Walker\n [\"01502\"] = 9, -- Daisy Walker\n [\"01002-pb\"] = 9, -- Daisy Walker\n [\"06003\"] = 10, -- Tony Morgan\n [\"04003\"] = 11, -- Finn Edwards\n [\"08016\"] = 14 -- Bob Jenkins\n }\n\n if smallToken ~= nil then\n setObjectState(smallToken, SPECIAL_ACTIONS[activeInvestigatorId] or STATE_TABLE[class])\n end\nend\n\nfunction setObjectState(obj, stateId)\n if obj.getStateId() ~= stateId then obj.setState(stateId) end\nend\n\n---------------------------------------------------------\n-- manipulation of owned objects\n---------------------------------------------------------\n\n-- updates the specific owned counter\n---@param param table Contains the information to update:\n--- type: String Counter to target\n--- newValue: Number Value to set the counter to\n--- modifier: Number If newValue is not provided, the existing value will be adjusted by this modifier\nfunction updateCounter(param)\n local counter = ownedObjects[param.type]\n if counter ~= nil then\n counter.call(\"updateVal\", param.newValue or (counter.getVar(\"val\") + param.modifier))\n else\n printToAll(param.type .. \" for \" .. matColor .. \" could not be found.\", \"Yellow\")\n end\nend\n\n-- returns the resource counter amount\n---@param type string Counter to target\nfunction getCounterValue(type)\n return ownedObjects[type].getVar(\"val\")\nend\n\n-- set investigator skill tracker to \"1, 1, 1, 1\"\nfunction resetSkillTracker()\n local obj = ownedObjects.InvestigatorSkillTracker\n if obj ~= nil then\n obj.call(\"updateStats\", { 1, 1, 1, 1 })\n else\n printToAll(\"Skill tracker for \" .. matColor .. \" playmat could not be found.\", \"Yellow\")\n end\nend\n\n---------------------------------------------------------\n-- calls to 'Global' / functions for calls from outside\n---------------------------------------------------------\n\nfunction drawChaosTokenButton(_, _, isRightClick)\n chaosBagApi.drawChaosToken(self, isRightClick)\nend\n\nfunction drawEncounterCard(_, _, isRightClick)\n mythosAreaApi.drawEncounterCard(self, isRightClick)\nend\n\nfunction returnGlobalDiscardPosition()\n return self.positionToWorld(DISCARD_PILE_POSITION)\nend\n\n-- Sets this playermat's draw 1 button to visible\n---@param visible boolean Whether the draw 1 button should be visible\nfunction showDrawButton(visible)\n isDrawButtonVisible = visible\n\n -- create the \"Draw 1\" button\n if isDrawButtonVisible then\n self.createButton({\n label = \"Draw 1\",\n click_function = \"doDrawOne\",\n function_owner = self,\n position = { 1.84, 0.1, -0.36 },\n scale = { 0.12, 0.12, 0.12 },\n width = 800,\n height = 280,\n font_size = 180\n })\n\n -- remove the \"Draw 1\" button\n else\n local buttons = self.getButtons()\n for i = 1, #buttons do\n if buttons[i].label == \"Draw 1\" then\n self.removeButton(buttons[i].index)\n end\n end\n end\nend\n\n-- shows / hides a clickable clue counter for this playmat and sets the correct amount of clues\n---@param showCounter boolean Whether the clickable clue counter should be visible\nfunction clickableClues(showCounter)\n local clickerPos = ownedObjects.ClickableClueCounter.getPosition()\n local clueCount = 0\n \n -- move clue counters\n local modY = showCounter and 0.525 or -0.525\n ownedObjects.ClickableClueCounter.setPosition(clickerPos + Vector(0, modY, 0))\n\n if showCounter then\n -- current clue count\n clueCount = ownedObjects.ClueCounter.getVar(\"exposedValue\")\n\n -- remove clues\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n\n -- set value for clue clickers\n ownedObjects.ClickableClueCounter.call(\"updateVal\", clueCount)\n else\n -- current clue count\n clueCount = ownedObjects.ClickableClueCounter.getVar(\"val\")\n\n -- spawn clues\n local pos = self.positionToWorld({x = -1.12, y = 0.05, z = 0.7})\n for i = 1, clueCount do\n pos.y = pos.y + 0.045 * i\n tokenManager.spawnToken(pos, \"clue\", self.getRotation())\n end\n end\nend\n\n-- removes all clues (moving tokens to the trash and setting counters to 0)\nfunction removeClues()\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n ownedObjects.ClickableClueCounter.call(\"updateVal\", 0)\nend\n\n-- reports the clue count\n---@param useClickableCounters boolean Controls which type of counter is getting checked\nfunction getClueCount(useClickableCounters)\n if useClickableCounters then\n return ownedObjects.ClickableClueCounter.getVar(\"val\")\n else\n return ownedObjects.ClueCounter.getVar(\"exposedValue\")\n end\nend\n\n-- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes\n-- is true, the main card slot snap points will only snap assets, while the investigator area point\n-- will only snap Investigators. If matchTypes is false, snap points will be reset to snap all cards.\n---@param matchTypes boolean Whether snap points should only snap for the matching card types.\nfunction setLimitSnapsByType(matchTypes)\n local snaps = self.getSnapPoints()\n for i, snap in ipairs(snaps) do\n local snapPos = snap.position\n if inArea(snapPos, MAIN_PLAY_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Asset\" }\n else\n table.insert(snaps[i].tags, \"Asset\")\n end\n else\n snaps[i].tags = nil\n end\n end\n if inArea(snapPos, INVESTIGATOR_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Investigator\" }\n else\n table.insert(snaps[i].tags, \"Investigator\")\n end\n else\n snaps[i].tags = nil\n end\n end\n end\n self.setSnapPoints(snaps)\nend\n\n-- Simple method to check if the given point is in a specified area. Local use only,\n---@param point tts__Vector Point to check, only x and z values are relevant\n---@param bounds table Defined area to see if the point is within. See MAIN_PLAY_AREA for sample\n-- bounds definition.\n---@return boolean: True if the point is in the area defined by bounds\nfunction inArea(point, bounds)\n return (point.x \u003c bounds.upperLeft.x\n and point.x \u003e bounds.lowerRight.x\n and point.z \u003c bounds.upperLeft.z\n and point.z \u003e bounds.lowerRight.z)\nend\n\n-- called by custom data helpers to add player card data\n---@param args table Contains only one entry, the GUID of the custom data helper\nfunction updatePlayerCards(args)\n local customDataHelper = getObjectFromGUID(args[1])\n local playerCardData = customDataHelper.getTable(\"PLAYER_CARD_DATA\")\n tokenManager.addPlayerCardData(playerCardData)\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot table New rotation for the object (optional)\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local newPos\n local offset = 0.5\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n else\n newPos = Vector(pos) + Vector(0, offset, 0)\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", - "LuaScriptState": "{\"activeInvestigatorId\":\"00000\",\"isDrawButtonVisible\":false,\"playerColor\":\"Red\"}", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/NavigationOverlayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local NavigationOverlayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getNOHandler()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"NavigationOverlayHandler\")\n end\n\n -- copies the visibility for the Navigation overlay\n ---@param startColor string Color of the player to copy from\n ---@param targetColor string Color of the targeted player\n NavigationOverlayApi.copyVisibility = function(startColor, targetColor)\n getNOHandler().call(\"copyVisibility\", {\n startColor = startColor,\n targetColor = targetColor\n })\n end\n\n -- changes the Navigation Overlay view (\"Full View\" --\u003e \"Play Areas\" --\u003e \"Closed\" etc.)\n ---@param playerColor string Color of the player to update the visibility for\n NavigationOverlayApi.cycleVisibility = function(playerColor)\n getNOHandler().call(\"cycleVisibility\", playerColor)\n end\n\n -- loads the specified camera for a player\n ---@param player tts__Player Player whose camera should be moved\n ---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to\n NavigationOverlayApi.loadCamera = function(player, camera)\n getNOHandler().call(\"loadCameraFromApi\", {\n player = player,\n camera = camera\n })\n end\n\n return NavigationOverlayApi\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot? table New rotation for the object\n ---@param below? boolean Should the object be placed below an existing deck?\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot, below)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local offset = 0.5\n local newPos = Vector(pos) + Vector(0, offset, 0)\n\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n if below then\n newPos = Vector(pos):setAt(\"y\", bounds.center.y - bounds.size.y / 2)\n else\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n end\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/Playmat\")\nend)\n__bundle_register(\"playermat/Playmat\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal deckLib = require(\"util/DeckLib\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal navigationOverlayApi = require(\"core/NavigationOverlayApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenChecker = require(\"core/token/TokenChecker\")\nlocal tokenManager = require(\"core/token/TokenManager\")\n\n-- we use this to turn off collision handling until onLoad() is complete\nlocal collisionEnabled = false\nlocal currentlyEditingSlots = false\n\n-- x-Values for discard buttons\nlocal DISCARD_BUTTON_X_START = -1.365\nlocal DISCARD_BUTTON_X_OFFSET = 0.455\n\nlocal SEARCH_AROUND_SELF_X_BUFFER = 8\n\n-- defined areas for object searching\nlocal MAIN_PLAY_AREA = {\n upperLeft = { x = 1.98, z = 0.736 },\n lowerRight = { x = -0.79, z = -0.39 }\n}\nlocal INVESTIGATOR_AREA = {\n upperLeft = { x = -1.084, z = 0.06517 },\n lowerRight = { x = -1.258, z = -0.0805 }\n}\nlocal THREAT_AREA = {\n upperLeft = { x = 1.53, z = -0.34 },\n lowerRight = { x = -1.13, z = -0.92 }\n}\nlocal DECK_DISCARD_AREA = {\n upperLeft = { x = -1.62, z = 0.855 },\n lowerRight = { x = -2.02, z = -0.245 },\n center = { x = -1.82, y = 0.5, z = 0.305 },\n size = { x = 0.4, y = 3, z = 1.1 }\n}\n\n-- local positions\nlocal DRAW_DECK_POSITION = { x = -1.82, y = 0.1, z = 0 }\nlocal DISCARD_PILE_POSITION = { x = -1.82, y = 0.1, z = 0.61 }\nlocal DRAWN_ENCOUNTER_POSITION = { x = 1.365, y = 0.5, z = -0.625 }\n\n-- global position of encounter discard pile\nlocal ENCOUNTER_DISCARD_POSITION = { x = -3.85, y = 1.5, z = 10.38 }\n\n-- used for the buttons on the right side of the playmat\n-- starts off with the data for the \"Upkeep\" button and will then be changed\nlocal buttonParameters = {\n label = \"Upkeep\",\n click_function = \"doUpkeep\",\n tooltip = \"Right-click to change color\",\n function_owner = self,\n position = { x = 1.82, y = 0.1, z = -0.45 },\n scale = { 0.12, 0.12, 0.12 },\n width = 1000,\n height = 280,\n font_size = 180\n}\n\n-- translation table for slot names to characters for special font\nlocal slotNameToChar = {\n [\"any\"] = \"\",\n [\"Accessory\"] = \"C\",\n [\"Ally\"] = \"E\",\n [\"Arcane\"] = \"G\",\n [\"Body\"] = \"K\",\n [\"Hand (right)\"] = \"M\",\n [\"Hand (left)\"] = \"M\",\n [\"Hand x2\"] = \"N\",\n [\"Tarot\"] = \"A\"\n}\n\n-- slot symbol for the respective slot (from top left to bottom right)\nlocal slotData = {}\nlocal defaultSlotData = {\n -- 1st row\n \"any\", \"any\", \"any\", \"Tarot\", \"Hand (left)\", \"Hand (right)\", \"Ally\",\n\n -- 2nd row\n \"any\", \"any\", \"any\", \"Accessory\", \"Arcane\", \"Arcane\", \"Body\"\n}\n\n-- global variable so it can be reset by the Clean Up Helper\nactiveInvestigatorId = \"00000\"\nlocal isDrawButtonVisible = false\n\n-- global variable to report \"Dream-Enhancing Serum\" status\nisDES = false\n\n-- table of type-object reference pairs of all owned objects\nlocal ownedObjects = {}\nlocal matColor = self.getMemo()\n\nfunction onSave()\n return JSON.encode({\n playerColor = playerColor,\n activeInvestigatorId = activeInvestigatorId,\n isDrawButtonVisible = isDrawButtonVisible,\n slotData = slotData\n })\nend\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n playerColor = loadedData.playerColor\n activeInvestigatorId = loadedData.activeInvestigatorId\n isDrawButtonVisible = loadedData.isDrawButtonVisible\n slotData = loadedData.slotData\n end\n\n self.interactable = false\n\n -- get object references to owned objects\n ownedObjects = guidReferenceApi.getObjectsByOwner(matColor)\n\n -- discard button creation\n for i = 1, 6 do\n makeDiscardButton(i)\n end\n\n self.createButton({\n click_function = \"drawEncounterCard\",\n function_owner = self,\n position = { -1.84, 0, -0.65 },\n rotation = { 0, 80, 0 },\n width = 265,\n height = 190\n })\n\n self.createButton({\n click_function = \"drawChaosTokenButton\",\n function_owner = self,\n position = { 1.85, 0, -0.74 },\n rotation = { 0, -45, 0 },\n width = 135,\n height = 135\n })\n\n -- Upkeep button: can use the default parameters for this\n self.createButton(buttonParameters)\n\n -- Slot editing button: modified default data\n buttonParameters.label = \"Edit Slots\"\n buttonParameters.click_function = \"toggleSlotEditing\"\n buttonParameters.tooltip = \"Right-click to reset slot symbols\"\n buttonParameters.position.z = 0.92\n self.createButton(buttonParameters)\n\n showDrawButton(isDrawButtonVisible)\n redrawSlotSymbols()\n math.randomseed(os.time())\n Wait.time(function() collisionEnabled = true end, 0.1)\nend\n\n---------------------------------------------------------\n-- utility functions\n---------------------------------------------------------\n\n-- searches an area and optionally filters the result\nfunction searchArea(origin, size, filter)\n return searchLib.inArea(origin, self.getRotation(), size, filter)\nend\n\n-- finds all objects on the playmat and associated set aside zone.\nfunction searchAroundSelf(filter)\n local bounds = self.getBoundsNormalized()\n -- Increase the width to cover the set aside zone\n bounds.size.x = bounds.size.x + SEARCH_AROUND_SELF_X_BUFFER\n bounds.size.y = 1\n -- Since the cast is centered on the position, shift left or right to keep the non-set aside edge\n -- of the cast at the edge of the playmat\n -- setAsideDirection accounts for the set aside zone being on the left or right, depending on the\n -- table position of the playmat\n local setAsideDirection = bounds.center.z \u003e 0 and 1 or -1\n local localCenter = self.positionToLocal(bounds.center)\n localCenter.x = localCenter.x + setAsideDirection * SEARCH_AROUND_SELF_X_BUFFER / 2 / self.getScale().x\n return searchArea(self.positionToWorld(localCenter), bounds.size, filter)\nend\n\n-- searches the area around the draw deck and discard pile\nfunction searchDeckAndDiscardArea(filter)\n local pos = self.positionToWorld(DECK_DISCARD_AREA.center)\n local scale = self.getScale()\n local size = {\n x = DECK_DISCARD_AREA.size.x * scale.x,\n y = DECK_DISCARD_AREA.size.y,\n z = DECK_DISCARD_AREA.size.z * scale.z\n }\n return searchArea(pos, size, filter)\nend\n\n-- rounds a number to the specified amount of decimal places\n---@param num number Initial value\n---@param numDecimalPlaces number Amount of decimal places\n---@return number: rounded number\nfunction round(num, numDecimalPlaces)\n local mult = 10 ^ (numDecimalPlaces or 0)\n return math.floor(num * mult + 0.5) / mult\nend\n\n-- edits the label of a button\n---@param oldLabel string Old label of the button\n---@param newLabel string New label of the button\nfunction editButtonLabel(oldLabel, newLabel)\n local buttons = self.getButtons()\n for i = 1, #buttons do\n if buttons[i].label == oldLabel then\n self.editButton({ index = buttons[i].index, label = newLabel })\n end\n end\nend\n\n-- updates the internal \"messageColor\" which is used for print/broadcast statements if no player is seated\n---@param clickedByColor string Colorstring of player who clicked a button\nfunction updateMessageColor(clickedByColor)\n messageColor = Player[playerColor].seated and playerColor or clickedByColor\nend\n\n---------------------------------------------------------\n-- Discard buttons\n---------------------------------------------------------\n\n-- handles discarding for a list of objects\n---@param objList table List of objects to discard\nfunction discardListOfObjects(objList)\n for _, obj in ipairs(objList) do\n if obj.type == \"Card\" or obj.type == \"Deck\" then\n if obj.hasTag(\"PlayerCard\") then\n deckLib.placeOrMergeIntoDeck(obj, returnGlobalDiscardPosition(), self.getRotation())\n else\n deckLib.placeOrMergeIntoDeck(obj, ENCOUNTER_DISCARD_POSITION, { x = 0, y = -90, z = 0 })\n end\n\n -- put chaos tokens back into bag (e.g. Unrelenting)\n elseif tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n\n -- don't touch locked objects (like the table etc.) or specific objects (like key tokens)\n elseif not obj.getLock() and not obj.hasTag(\"DontDiscard\") then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n-- build a discard button to discard from searchPosition\n---@param id number Index of the discard button (from left to right, must be unique)\nfunction makeDiscardButton(id)\n local xValue = DISCARD_BUTTON_X_START + (id - 1) * DISCARD_BUTTON_X_OFFSET\n local position = { xValue, 0.1, -0.94 }\n local searchPosition = { -position[1], position[2], position[3] + 0.32 }\n local handlerName = 'handler' .. id\n self.setVar(handlerName, function()\n local cardSizeSearch = { 2, 1, 3.2 }\n local globalSearchPosition = self.positionToWorld(searchPosition)\n local searchResult = searchArea(globalSearchPosition, cardSizeSearch)\n return discardListOfObjects(searchResult)\n end)\n self.createButton({\n label = \"Discard\",\n click_function = handlerName,\n function_owner = self,\n position = position,\n scale = { 0.12, 0.12, 0.12 },\n width = 900,\n height = 350,\n font_size = 220\n })\nend\n\n---------------------------------------------------------\n-- Upkeep button\n---------------------------------------------------------\n\n-- calls the Upkeep function with correct parameter\nfunction doUpkeepFromHotkey(clickedByColor)\n doUpkeep(_, clickedByColor)\nend\n\nfunction doUpkeep(_, clickedByColor, isRightClick)\n if isRightClick then\n changeColor(clickedByColor)\n return\n end\n\n updateMessageColor(clickedByColor)\n\n -- unexhaust cards in play zone, flip action tokens and find forcedLearning\n local forcedLearning = false\n local rot = self.getRotation()\n for _, obj in ipairs(searchAroundSelf()) do\n if obj.getDescription() == \"Action Token\" and obj.is_face_down then\n obj.flip()\n elseif obj.type == \"Card\" and not inArea(self.positionToLocal(obj.getPosition()), INVESTIGATOR_AREA) then\n local cardMetadata = JSON.decode(obj.getGMNotes()) or {}\n if not (obj.getVar(\"do_not_ready\") or false) then\n local cardRotation = round(obj.getRotation().y, 0) - rot.y\n local yRotDiff = 0\n\n if cardRotation \u003c 0 then\n cardRotation = cardRotation + 360\n end\n\n -- rotate cards to the next multiple of 90° towards 0°\n if cardRotation \u003e 90 and cardRotation \u003c= 180 then\n yRotDiff = 90\n elseif cardRotation \u003c 270 and cardRotation \u003e 180 then\n yRotDiff = 270\n end\n\n -- set correct rotation for face-down cards\n rot.z = obj.is_face_down and 180 or 0\n obj.setRotation({ rot.x, rot.y + yRotDiff, rot.z })\n end\n\n -- detect forced learning to handle card drawing accordingly\n if cardMetadata.id == \"08031\" then\n forcedLearning = true\n end\n\n -- maybe replenish uses on certain cards\n if cardMetadata.uses ~= nil then\n tokenManager.maybeReplenishCard(obj, cardMetadata.uses, self)\n end\n elseif obj.type == \"Deck\" and forcedLearning == false then\n -- check decks for forced learning\n for _, deepObj in ipairs(obj.getObjects()) do\n local cardMetadata = JSON.decode(deepObj.gm_notes) or {}\n if cardMetadata.id == \"08031\" then\n forcedLearning = true\n end\n end\n end\n end\n\n -- flip investigator mini-card and summoned servitor mini-card\n -- (all characters allowed to account for custom IDs - e.g. 'Z0000' for TTS Zoop generated IDs)\n local miniId = string.match(activeInvestigatorId, \".....\") .. \"-m\"\n for _, obj in ipairs(getObjects()) do\n if obj.type == \"Card\" and obj.is_face_down then\n local notes = JSON.decode(obj.getGMNotes())\n if notes ~= nil and notes.type == \"Minicard\" and (notes.id == miniId or notes.id == \"09080-m\") then\n obj.flip()\n end\n end\n end\n\n -- gain a resource (or two if playing Jenny Barnes)\n if string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"02003\" then\n updateCounter({ type = \"ResourceCounter\", modifier = 2 })\n printToColor(\"Gaining 2 resources (Jenny)\", messageColor)\n else\n updateCounter({ type = \"ResourceCounter\", modifier = 1 })\n end\n\n -- draw a card (with handling for Patrice and Forced Learning)\n if activeInvestigatorId == \"06005\" then\n if forcedLearning then\n printToColor(\"Wow, did you really take 'Versatile' to play Patrice with 'Forced Learning'?\"\n .. \" Choose which draw replacement effect takes priority and draw cards accordingly.\", messageColor)\n else\n local handSize = #Player[playerColor].getHandObjects()\n if handSize \u003c 5 then\n local cardsToDraw = 5 - handSize\n printToColor(\"Drawing \" .. cardsToDraw .. \" cards (Patrice)\", messageColor)\n drawCardsWithReshuffle(cardsToDraw)\n end\n end\n elseif forcedLearning then\n printToColor(\"Drawing 2 cards, discard 1 (Forced Learning)\", messageColor)\n drawCardsWithReshuffle(2)\n elseif activeInvestigatorId == \"89001\" then\n printToColor(\"Drawing 2 cards (Subject 5U-21)\", messageColor)\n drawCardsWithReshuffle(2)\n else\n drawCardsWithReshuffle(1)\n end\nend\n\n-- click function for \"draw 1 button\" (that can be added via option panel)\nfunction doDrawOne(_, clickedByColor)\n updateMessageColor(clickedByColor)\n drawCardsWithReshuffle(1)\nend\n\n-- draws the specified amount of cards (and shuffles the discard if necessary)\n---@param numCards number Number of cards to draw\nfunction drawCardsWithReshuffle(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n\n -- Norman Withers handling\n local harbinger = false\n if deckAreaObjects.topCard and deckAreaObjects.topCard.getName() == \"The Harbinger\" then\n harbinger = true\n elseif deckAreaObjects.draw and not deckAreaObjects.draw.is_face_down then\n local cards = deckAreaObjects.draw.getObjects()\n if cards[#cards].name == \"The Harbinger\" then\n harbinger = true\n end\n end\n\n if harbinger then\n printToColor(\"The Harbinger is on top of your deck, not drawing cards\", messageColor)\n return\n end\n\n local topCardDetected = false\n if deckAreaObjects.topCard ~= nil then\n deckAreaObjects.topCard.deal(1, playerColor)\n topCardDetected = true\n numCards = numCards - 1\n if numCards == 0 then\n flipTopCardFromDeck()\n return\n end\n end\n\n local deckSize = 1\n if deckAreaObjects.draw == nil then\n deckSize = 0\n elseif deckAreaObjects.draw.type == \"Deck\" then\n deckSize = #deckAreaObjects.draw.getObjects()\n end\n\n if deckSize \u003e= numCards then\n drawCards(numCards)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n else\n drawCards(deckSize)\n if deckAreaObjects.discard ~= nil then\n shuffleDiscardIntoDeck()\n Wait.time(function()\n drawCards(numCards - deckSize)\n -- flip top card again for Norman\n if topCardDetected and string.match(activeInvestigatorId, \"%d%d%d%d%d\") == \"08004\" then\n flipTopCardFromDeck()\n end\n end, 1)\n end\n printToColor(\"Take 1 horror (drawing card from empty deck)\", messageColor)\n end\nend\n\n-- get the draw deck and discard pile objects and returns the references\n---@return table: string-indexed table with references to the found objects\nfunction getDeckAreaObjects()\n local deckAreaObjects = {}\n for _, object in ipairs(searchDeckAndDiscardArea(\"isCardOrDeck\")) do\n if self.positionToLocal(object.getPosition()).z \u003e 0.5 then\n deckAreaObjects.discard = object\n -- Norman Withers handling\n elseif object.type == \"Card\" and not object.is_face_down then\n deckAreaObjects.topCard = object\n else\n deckAreaObjects.draw = object\n end\n end\n return deckAreaObjects\nend\n\n-- draws the specified number of cards (reshuffling of discard pile is handled separately)\n---@param numCards number Number of cards to draw\nfunction drawCards(numCards)\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.draw then\n deckAreaObjects.draw.deal(numCards, playerColor)\n end\nend\n\nfunction shuffleDiscardIntoDeck()\n local deckAreaObjects = getDeckAreaObjects()\n if not deckAreaObjects.discard.is_face_down then\n deckAreaObjects.discard.flip()\n end\n deckAreaObjects.discard.shuffle()\n deckAreaObjects.discard.setPositionSmooth(self.positionToWorld(DRAW_DECK_POSITION), false, false)\nend\n\n-- utility function for Norman Withers to flip the top card to the revealed side\nfunction flipTopCardFromDeck()\n Wait.time(function()\n local deckAreaObjects = getDeckAreaObjects()\n if deckAreaObjects.topCard then\n elseif deckAreaObjects.draw then\n if deckAreaObjects.draw.type == \"Card\" then\n deckAreaObjects.draw.flip()\n else\n -- get bounds to know the height of the deck\n local bounds = deckAreaObjects.draw.getBounds()\n local pos = bounds.center + Vector(0, bounds.size.y / 2 + 0.2, 0)\n deckAreaObjects.draw.takeObject({ position = pos, flip = true })\n end\n end\n end, 0.1)\nend\n\n-- discard a random non-hidden card from hand\nfunction doDiscardOne()\n local hand = Player[playerColor].getHandObjects()\n if #hand == 0 then\n broadcastToColor(\"Cannot discard from empty hand!\", messageColor, \"Red\")\n else\n local choices = {}\n for i = 1, #hand do\n local notes = JSON.decode(hand[i].getGMNotes())\n if notes ~= nil then\n if notes.hidden ~= true then\n table.insert(choices, i)\n end\n else\n table.insert(choices, i)\n end\n end\n\n if #choices == 0 then\n broadcastToColor(\"Hidden cards can't be randomly discarded.\", messageColor, \"Orange\")\n return\n end\n\n -- get a random non-hidden card (from the \"choices\" table)\n local num = math.random(1, #choices)\n deckLib.placeOrMergeIntoDeck(hand[choices[num]], returnGlobalDiscardPosition(), self.getRotation())\n\n local playerName = Player[playerColor].steam_name or playerColor\n broadcastToAll(playerName .. \" randomly discarded card \" .. choices[num] .. \"/\" .. #hand .. \".\", \"White\")\n end\nend\n\n---------------------------------------------------------\n-- slot symbol displaying\n---------------------------------------------------------\n\n-- this will redraw the XML for the slot symbols based on the slotData table\nfunction redrawSlotSymbols()\n local xml = {}\n local snapId = 0\n\n -- use the snap point positions in the main play area for positions\n for _, snap in ipairs(self.getSnapPoints()) do\n if inArea(snap.position, MAIN_PLAY_AREA) then\n snapId = snapId + 1\n local slotName = slotData[snapId]\n\n -- conversion from regular coordinates to XML\n local x = snap.position.x * 100\n local y = snap.position.z * 100\n\n -- XML for a single slot (panel with text in the special font)\n local slotXML = {\n tag = \"Panel\",\n attributes = {\n id = \"slotPanel\" .. snapId,\n scale = \"0.1 0.1 1\",\n width = \"175\",\n height = \"175\",\n position = x .. \" \" .. y .. \" -11\"\n },\n children = {\n {\n tag = \"Text\",\n attributes = {\n id = \"slot\" .. snapId,\n rotation = getSlotRotation(slotName),\n fontSize = \"145\",\n font = \"font_arkhamicons\",\n color = \"#414141CB\",\n text = slotNameToChar[slotName]\n }\n }\n }\n }\n table.insert(xml, slotXML)\n end\n end\n\n self.UI.setXmlTable(xml)\nend\n\n-- toggle the \"slot editing mode\"\nfunction toggleSlotEditing(_, clickedByColor, isRightClick)\n if isRightClick then\n resetSlotSymbols()\n return\n end\n\n updateMessageColor(clickedByColor)\n\n -- toggle internal variable\n currentlyEditingSlots = not currentlyEditingSlots\n\n if currentlyEditingSlots then\n editButtonLabel(\"Edit Slots\", \"Stop editing\")\n broadcastToColor(\"Click on a slot symbol (or an empty slot) to edit it.\", messageColor, \"Orange\")\n addClickFunctionToSlots()\n else\n editButtonLabel(\"Stop editing\", \"Edit Slots\")\n redrawSlotSymbols()\n end\nend\n\n-- click function for slot symbols during the \"slot editing mode\"\nfunction slotClickfunction(player, _, id)\n local slotIndex = id:gsub(\"slotPanel\", \"\")\n slotIndex = tonumber(slotIndex)\n\n -- make a list of the table keys as options for the dialog box\n local slotNames = {}\n for slotName, _ in pairs(slotNameToChar) do\n table.insert(slotNames, slotName)\n end\n\n -- prompt player to choose symbol\n player.showOptionsDialog(\"Choose Slot Symbol\", slotNames, slotData[slotIndex],\n function(chosenSlotName)\n slotData[slotIndex] = chosenSlotName\n\n -- update slot symbol\n self.UI.setAttribute(\"slot\" .. slotIndex, \"text\", slotNameToChar[chosenSlotName])\n\n -- update slot rotation\n self.UI.setAttribute(\"slot\" .. slotIndex, \"rotation\", getSlotRotation(chosenSlotName))\n end\n )\nend\n\n-- helper function to rotate the left hand\nfunction getSlotRotation(slotName)\n if slotName == \"Hand (left)\" then\n return \"0 180 180\"\n else\n return \"0 0 180\"\n end\nend\n\n-- reset the slot symbols by making a deep copy of the default data and redrawing\nfunction resetSlotSymbols()\n slotData = {}\n for _, slotName in ipairs(defaultSlotData) do\n table.insert(slotData, slotName)\n end\n\n redrawSlotSymbols()\n\n -- need to re-add the click functions if currently in edit mode\n if currentlyEditingSlots then\n addClickFunctionToSlots()\n end\nend\n\n-- enables the click functions for editing\nfunction addClickFunctionToSlots()\n for i = 1, #slotData do\n self.UI.setAttribute(\"slotPanel\" .. i, \"onClick\", \"slotClickfunction\")\n end\nend\n\n---------------------------------------------------------\n-- color related functions\n---------------------------------------------------------\n\n-- changes the player color\nfunction changeColor(clickedByColor)\n local colorList = Player.getColors()\n\n -- remove existing colors from the list of choices\n for _, existingColor in ipairs(Player.getAvailableColors()) do\n for i, newColor in ipairs(colorList) do\n if existingColor == newColor or newColor == \"Black\" or newColor == \"Grey\" then\n table.remove(colorList, i)\n end\n end\n end\n\n -- show the option dialog for color selection to the player that triggered this\n Player[clickedByColor].showOptionsDialog(\"Select a new color:\", colorList, _, function(color)\n -- update the color of the hand zone\n local handZone = ownedObjects.HandZone\n handZone.setValue(color)\n\n -- if the seated player clicked this, reseat him to the new color\n if clickedByColor == playerColor then\n navigationOverlayApi.copyVisibility(playerColor, color)\n Player[playerColor].changeColor(color)\n end\n\n -- update the internal variable\n playerColor = color\n end)\nend\n\n---------------------------------------------------------\n-- playmat token spawning\n---------------------------------------------------------\n\n-- Finds all customizable cards in this play area and updates their metadata based on the selections\n-- on the matching upgrade sheet.\n-- This method is theoretically O(n^2), and should be used sparingly. In practice it will only be\n-- called when a checkbox is added or removed in-game (which should be rare), and is bounded by the\n-- number of customizable cards in play.\nfunction syncAllCustomizableCards()\n for _, card in ipairs(searchAroundSelf(\"isCard\")) do\n syncCustomizableMetadata(card)\n end\nend\n\nfunction syncCustomizableMetadata(card)\n local cardMetadata = JSON.decode(card.getGMNotes()) or {}\n if cardMetadata == nil or cardMetadata.customizations == nil then return end\n\n for _, upgradeSheet in ipairs(searchAroundSelf(\"isCard\")) do\n local upgradeSheetMetadata = JSON.decode(upgradeSheet.getGMNotes()) or {}\n if upgradeSheetMetadata.id == (cardMetadata.id .. \"-c\") then\n for i, customization in ipairs(cardMetadata.customizations) do\n if customization.replaces ~= nil and customization.replaces.uses ~= nil then\n if upgradeSheet.call(\"isUpgradeActive\", i) then\n cardMetadata.uses = customization.replaces.uses\n card.setGMNotes(JSON.encode(cardMetadata))\n else\n -- TODO: Get the original metadata to restore it... maybe. This should only be\n -- necessary in the very unlikely case that a user un-checks a previously-full upgrade\n -- row while the card is in play. It will be much easier once the AllPlayerCardsApi is\n -- in place, so defer until it is\n end\n end\n end\n end\n end\nend\n\nfunction spawnTokensFor(object)\n local extraUses = {}\n if activeInvestigatorId == \"03004\" then\n extraUses[\"Charge\"] = 1\n end\n\n tokenManager.spawnForCard(object, extraUses)\nend\n\nfunction onCollisionEnter(collisionInfo)\n local object = collisionInfo.collision_object\n\n -- only continue if loading is completed\n if not collisionEnabled then return end\n\n -- only continue for cards\n if object.type ~= \"Card\" then return end\n\n -- detect if \"Dream-Enhancing Serum\" is placed\n if object.getName() == \"Dream-Enhancing Serum\" then isDES = true end\n\n maybeUpdateActiveInvestigator(object)\n syncCustomizableMetadata(object)\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n elseif shouldSpawnTokens(object) then\n spawnTokensFor(object)\n end\nend\n\n-- detect if \"Dream-Enhancing Serum\" is removed\nfunction onCollisionExit(collisionInfo)\n if collisionInfo.collision_object.getName() == \"Dream-Enhancing Serum\" then isDES = false end\nend\n\n-- checks if tokens should be spawned for the provided card\nfunction shouldSpawnTokens(card)\n if card.is_face_down then\n return false\n end\n\n local localCardPos = self.positionToLocal(card.getPosition())\n local metadata = JSON.decode(card.getGMNotes())\n\n -- If no metadata we don't know the type, so only spawn in the main area\n if metadata == nil then\n return inArea(localCardPos, MAIN_PLAY_AREA)\n end\n\n -- Spawn tokens for assets and events on the main area\n if inArea(localCardPos, MAIN_PLAY_AREA)\n and (metadata.type == \"Asset\"\n or metadata.type == \"Event\") then\n return true\n end\n\n -- Spawn tokens for all encounter types in the threat area\n if inArea(localCardPos, THREAT_AREA)\n and (metadata.type == \"Treachery\"\n or metadata.type == \"Enemy\"\n or metadata.weakness) then\n return true\n end\n\n return false\nend\n\nfunction onObjectEnterContainer(container, object)\n if object.type ~= \"Card\" then return end\n\n local localCardPos = self.positionToLocal(object.getPosition())\n if inArea(localCardPos, DECK_DISCARD_AREA) then\n tokenManager.resetTokensSpawned(object)\n removeTokensFromObject(object)\n end\nend\n\n-- removes tokens from the provided card/deck\nfunction removeTokensFromObject(object)\n if object.hasTag(\"CardThatSeals\") then\n local func = object.getVar(\"resetSealedTokens\") -- check if function exists (it won't for older custom content)\n if func ~= nil then\n object.call(\"resetSealedTokens\")\n end\n end\n\n for _, obj in ipairs(searchLib.onObject(object)) do\n if tokenChecker.isChaosToken(obj) then\n chaosBagApi.returnChaosTokenToBag(obj)\n elseif obj.getGUID() ~= \"4ee1f2\" and -- table\n obj ~= self and\n obj.type ~= \"Deck\" and\n obj.type ~= \"Card\" and\n obj.memo ~= nil and\n obj.getLock() == false and\n obj.getDescription() ~= \"Action Token\" then\n ownedObjects.Trash.putObject(obj)\n end\n end\nend\n\n---------------------------------------------------------\n-- investigator ID grabbing and skill tracker\n---------------------------------------------------------\n\n-- updates the internal investigator id and action tokens if an investigator card is detected\n---@param card tts__Object Card that might be an investigator\nfunction maybeUpdateActiveInvestigator(card)\n if not inArea(self.positionToLocal(card.getPosition()), INVESTIGATOR_AREA) then return end\n\n local notes = JSON.decode(card.getGMNotes())\n local class\n\n if notes ~= nil and notes.type == \"Investigator\" and notes.id ~= nil then\n if notes.id == activeInvestigatorId then return end\n class = notes.class\n activeInvestigatorId = notes.id\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", {\n notes.willpowerIcons,\n notes.intellectIcons,\n notes.combatIcons,\n notes.agilityIcons\n })\n elseif activeInvestigatorId ~= \"00000\" then\n class = \"Neutral\"\n activeInvestigatorId = \"00000\"\n ownedObjects.InvestigatorSkillTracker.call(\"updateStats\", { 1, 1, 1, 1 })\n else\n return\n end\n\n -- change state of action tokens\n local search = searchArea(self.positionToWorld({ -1.1, 0.05, -0.27 }), { 4, 1, 1 })\n local smallToken = nil\n local STATE_TABLE = {\n [\"Guardian\"] = 1,\n [\"Seeker\"] = 2,\n [\"Rogue\"] = 3,\n [\"Mystic\"] = 4,\n [\"Survivor\"] = 5,\n [\"Neutral\"] = 6\n }\n\n for _, obj in ipairs(search) do\n if obj.getDescription() == \"Action Token\" and obj.getStateId() \u003e 0 then\n if obj.getScale().x \u003c 0.4 then\n smallToken = obj\n else\n setObjectState(obj, STATE_TABLE[class])\n end\n end\n end\n\n -- update the small token with special action for certain investigators\n local SPECIAL_ACTIONS = {\n [\"04002\"] = 8, -- Ursula Downs\n [\"01002\"] = 9, -- Daisy Walker\n [\"01502\"] = 9, -- Daisy Walker\n [\"01002-pb\"] = 9, -- Daisy Walker\n [\"06003\"] = 10, -- Tony Morgan\n [\"04003\"] = 11, -- Finn Edwards\n [\"08016\"] = 14 -- Bob Jenkins\n }\n\n if smallToken ~= nil then\n setObjectState(smallToken, SPECIAL_ACTIONS[activeInvestigatorId] or STATE_TABLE[class])\n end\nend\n\nfunction setObjectState(obj, stateId)\n if obj.getStateId() ~= stateId then obj.setState(stateId) end\nend\n\n---------------------------------------------------------\n-- manipulation of owned objects\n---------------------------------------------------------\n\n-- updates the specified owned counter\n---@param param table Contains the information to update:\n--- type: String Counter to target\n--- newValue: Number Value to set the counter to\n--- modifier: Number If newValue is not provided, the existing value will be adjusted by this modifier\nfunction updateCounter(param)\n local counter = ownedObjects[param.type]\n if counter ~= nil then\n counter.call(\"updateVal\", param.newValue or (counter.getVar(\"val\") + param.modifier))\n else\n printToAll(param.type .. \" for \" .. matColor .. \" could not be found.\", \"Yellow\")\n end\nend\n\n-- get the value the specified owned counter\n---@param type string Counter to target\n---@return number: Counter value\nfunction getCounterValue(type)\n return ownedObjects[type].getVar(\"val\")\nend\n\n-- set investigator skill tracker to \"1, 1, 1, 1\"\nfunction resetSkillTracker()\n local obj = ownedObjects.InvestigatorSkillTracker\n if obj ~= nil then\n obj.call(\"updateStats\", { 1, 1, 1, 1 })\n else\n printToAll(\"Skill tracker for \" .. matColor .. \" playmat could not be found.\", \"Yellow\")\n end\nend\n\n---------------------------------------------------------\n-- calls to 'Global' / functions for calls from outside\n---------------------------------------------------------\n\nfunction drawChaosTokenButton(_, _, isRightClick)\n chaosBagApi.drawChaosToken(self, isRightClick)\nend\n\nfunction drawEncounterCard(_, _, isRightClick)\n local drawPos = getEncounterCardDrawPosition(not isRightClick)\n mythosAreaApi.drawEncounterCard(matColor, drawPos)\nend\n\nfunction returnGlobalDiscardPosition()\n return self.positionToWorld(DISCARD_PILE_POSITION)\nend\n\nfunction returnGlobalDrawPosition()\n return self.positionToWorld(DRAW_DECK_POSITION)\nend\n\n-- returns the position for encounter card drawing\n---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\nfunction getEncounterCardDrawPosition(stack)\n local drawPos = self.positionToWorld(DRAWN_ENCOUNTER_POSITION)\n\n -- maybe override position with first empty slot in threat area (right to left)\n if not stack then\n local searchPos = Vector(-0.91, 0.5, -0.625)\n for i = 1, 5 do\n local globalSearchPos = self.positionToWorld(searchPos)\n local searchResult = searchLib.atPosition(globalSearchPos, \"isCardOrDeck\")\n if #searchResult == 0 then\n drawPos = globalSearchPos\n break\n else\n searchPos.x = searchPos.x + 0.455\n end\n end\n end\n\n return drawPos\nend\n\n-- creates / removes the draw 1 button\n---@param visible boolean Whether the draw 1 button should be visible\nfunction showDrawButton(visible)\n isDrawButtonVisible = visible\n\n if isDrawButtonVisible then\n -- Draw 1 button: modified default data\n buttonParameters.label = \"Draw 1\"\n buttonParameters.click_function = \"doDrawOne\"\n buttonParameters.tooltip = \"\"\n buttonParameters.position.z = -0.35\n self.createButton(buttonParameters)\n else\n local buttons = self.getButtons()\n for i = 1, #buttons do\n if buttons[i].label == \"Draw 1\" then\n self.removeButton(buttons[i].index)\n end\n end\n end\nend\n\n-- shows / hides a clickable clue counter for this playmat and sets the correct amount of clues\n---@param showCounter boolean Whether the clickable clue counter should be visible\nfunction clickableClues(showCounter)\n local clickerPos = ownedObjects.ClickableClueCounter.getPosition()\n local clueCount = 0\n\n -- move clue counters\n local modY = showCounter and 0.525 or -0.525\n ownedObjects.ClickableClueCounter.setPosition(clickerPos + Vector(0, modY, 0))\n\n if showCounter then\n -- get current clue count\n clueCount = ownedObjects.ClueCounter.getVar(\"exposedValue\")\n\n -- remove clues\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n\n -- set value for clue clickers\n ownedObjects.ClickableClueCounter.call(\"updateVal\", clueCount)\n else\n -- get current clue count\n clueCount = ownedObjects.ClickableClueCounter.getVar(\"val\")\n\n -- spawn clues\n local pos = self.positionToWorld({ x = -1.12, y = 0.05, z = 0.7 })\n for i = 1, clueCount do\n pos.y = pos.y + 0.045 * i\n tokenManager.spawnToken(pos, \"clue\", self.getRotation())\n end\n end\nend\n\n-- removes all clues (moving tokens to the trash and setting counters to 0)\nfunction removeClues()\n ownedObjects.ClueCounter.call(\"removeAllClues\", ownedObjects.Trash)\n ownedObjects.ClickableClueCounter.call(\"updateVal\", 0)\nend\n\n-- reports the clue count\n---@param useClickableCounters boolean Controls which type of counter is getting checked\nfunction getClueCount(useClickableCounters)\n if useClickableCounters then\n return ownedObjects.ClickableClueCounter.getVar(\"val\")\n else\n return ownedObjects.ClueCounter.getVar(\"exposedValue\")\n end\nend\n\n-- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes\n-- is true, the main card slot snap points will only snap assets, while the investigator area point\n-- will only snap Investigators. If matchTypes is false, snap points will be reset to snap all cards.\n---@param matchTypes boolean Whether snap points should only snap for the matching card types.\nfunction setLimitSnapsByType(matchTypes)\n local snaps = self.getSnapPoints()\n for i, snap in ipairs(snaps) do\n if inArea(snap.position, MAIN_PLAY_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Asset\" }\n else\n table.insert(snaps[i].tags, \"Asset\")\n end\n else\n snaps[i].tags = nil\n end\n end\n if inArea(snap.position, INVESTIGATOR_AREA) then\n local snapTags = snaps[i].tags\n if matchTypes then\n if snapTags == nil then\n snaps[i].tags = { \"Investigator\" }\n else\n table.insert(snaps[i].tags, \"Investigator\")\n end\n else\n snaps[i].tags = nil\n end\n end\n end\n self.setSnapPoints(snaps)\nend\n\n-- Simple method to check if the given point is in a specified area. Local use only\n---@param point tts__Vector Point to check, only x and z values are relevant\n---@param bounds table Defined area to see if the point is within. See MAIN_PLAY_AREA for sample bounds definition.\n---@return boolean: True if the point is in the area defined by bounds\nfunction inArea(point, bounds)\n return (point.x \u003c bounds.upperLeft.x\n and point.x \u003e bounds.lowerRight.x\n and point.z \u003c bounds.upperLeft.z\n and point.z \u003e bounds.lowerRight.z)\nend\n\n-- called by custom data helpers to add player card data\n---@param args table Contains only one entry, the GUID of the custom data helper\nfunction updatePlayerCards(args)\n local customDataHelper = getObjectFromGUID(args[1])\n local playerCardData = customDataHelper.getTable(\"PLAYER_CARD_DATA\")\n tokenManager.addPlayerCardData(playerCardData)\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat to the first empty spot from the right \n ---@param matColor string Playermat that triggered this\n ---@param position tts__Vector Position for the encounter card\n MythosAreaApi.drawEncounterCard = function(matColor, position)\n getMythosArea().call(\"drawEncounterCard\", { matColor = matColor, position = position })\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"core/token/TokenChecker\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local CHAOS_TOKEN_NAMES = {\n [\"Elder Sign\"] = true,\n [\"+1\"] = true,\n [\"0\"] = true,\n [\"-1\"] = true,\n [\"-2\"] = true,\n [\"-3\"] = true,\n [\"-4\"] = true,\n [\"-5\"] = true,\n [\"-6\"] = true,\n [\"-7\"] = true,\n [\"-8\"] = true,\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n [\"Auto-fail\"] = true,\n [\"Bless\"] = true,\n [\"Curse\"] = true,\n [\"Frost\"] = true\n }\n\n local TokenChecker = {}\n\n -- returns true if the passed object is a chaos token (by name)\n TokenChecker.isChaosToken = function(obj)\n if obj.type == \"Tile\" and CHAOS_TOKEN_NAMES[obj.getName()] then\n return true\n else\n return false\n end\n end\n\n return TokenChecker\nend\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned)\n -- token starts in state 1, so don't attempt to change it to avoid error\n if tokenValue ~= 1 then\n spawned.setState(tokenValue)\n end\n end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScriptState": "{\"activeInvestigatorId\":\"00000\",\"isDrawButtonVisible\":false,\"playerColor\":\"Red\",\"slotData\":[\"any\",\"any\",\"any\",\"Tarot\",\"Hand (left)\",\"Hand (right)\",\"Ally\",\"any\",\"any\",\"any\",\"Accessory\",\"Arcane\",\"Arcane\",\"Body\"]}", "MeasureMovement": false, "Memo": "Red", "Name": "Custom_Tile", @@ -88423,7 +88433,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"arkhamdb/DeckImporterMain\")\nend)\n__bundle_register(\"arkhamdb/ArkhamDb\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local allCardsBagApi = require(\"playercards/AllCardsBagApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n\n local ArkhamDb = {}\n local internal = {}\n \n local tabooList = {}\n local configuration\n\n local RANDOM_WEAKNESS_ID = \"01000\"\n\n ---@class Request\n local Request = {}\n\n -- Sets up the ArkhamDb interface. Should be called from the parent object on load.\n ArkhamDb.initialize = function()\n configuration = internal.getConfiguration()\n Request.start({ configuration.api_uri, configuration.taboo }, function(status)\n local json = JSON.decode(internal.fixUtf16String(status.text))\n for _, taboo in pairs(json) do\n local cards = {}\n\n for _, card in pairs(JSON.decode(taboo.cards)) do\n cards[card.code] = true\n end\n\n tabooList[taboo.id] = {\n date = taboo.date_start,\n cards = cards\n }\n end\n return true, nil\n end)\n end\n\n -- Start the deck build process for the given player color and deck ID. This\n -- will retrieve the deck from ArkhamDB, and pass to a callback for processing.\n ---@param playerColor string Color name of the player mat to place this deck on (e.g. \"Red\").\n ---@param deckId string ArkhamDB deck id to be loaded\n ---@param isPrivate boolean Whether this deck is published or private on ArkhamDB\n ---@param loadNewest boolean Whether the newest version of this deck should be loaded\n ---@param loadInvestigators boolean Whether investigator cards should be loaded as part of this deck\n ---@param callback function Callback which will be sent the results of this load\n --- Parameters to the callback will be:\n --- slots table A map of card ID to count in the deck\n --- investigatorCode String. ID of the investigator in this deck\n --- customizations table The decoded table of customization upgrades in this deck\n --- playerColor String. Color this deck is being loaded for\n ---@return boolean\n ---@return string\n ArkhamDb.getDecklist = function(\n playerColor,\n deckId,\n isPrivate,\n loadNewest,\n loadInvestigators,\n callback)\n -- Get a simple card to see if the bag indexes are complete. If not, abort\n -- the deck load. The called method will handle player notification.\n local checkCard = allCardsBagApi.getCardById(\"01001\")\n if (checkCard ~= nil and checkCard.data == nil) then\n return false, \"Indexing not complete\"\n end\n\n local deckUri = {\n configuration.api_uri,\n isPrivate and configuration.private_deck or configuration.public_deck,\n deckId\n }\n\n local deck = Request.start(deckUri, function(status)\n if string.find(status.text, \"\u003c!DOCTYPE html\u003e\") then\n internal.maybePrint(\"Private deck ID \" .. deckId .. \" is not shared\", playerColor)\n return false, \"Private deck \" .. deckId .. \" is not shared\"\n end\n local json = JSON.decode(status.text)\n\n if not json then\n internal.maybePrint(\"Deck ID \" .. deckId .. \" not found\", playerColor)\n return false, \"Deck not found!\"\n end\n\n return true, json\n end)\n\n deck:with(internal.onDeckResult, playerColor, loadNewest, loadInvestigators, callback)\n end\n\n -- Logs that a card could not be loaded in the mod by printing it to the console in the given\n -- color of the player owning the deck. Attempts to look up the name on ArkhamDB for clarity,\n -- but prints the card ID if the name cannot be retrieved.\n ---@param cardId string ArkhamDB ID of the card that could not be found\n ---@param playerColor string Color of the player's deck that had the problem\n ArkhamDb.logCardNotFound = function(cardId, playerColor)\n local request = Request.start({\n configuration.api_uri,\n configuration.cards,\n cardId\n },\n function(result)\n local adbCardInfo = JSON.decode(internal.fixUtf16String(result.text))\n local cardName = adbCardInfo.real_name\n if (cardName ~= nil) then\n if (adbCardInfo.xp ~= nil and adbCardInfo.xp \u003e 0) then\n cardName = cardName .. \" (\" .. adbCardInfo.xp .. \")\"\n end\n internal.maybePrint(\"Card not found: \" .. cardName .. \", card ID \" .. cardId, playerColor)\n else\n internal.maybePrint(\"Card not found in ArkhamDB/Index, ID \" .. cardId, playerColor)\n end\n end)\n end\n\n -- Callback when the deck information is received from ArkhamDB. Parses the\n -- response then applies standard transformations to the deck such as adding\n -- random weaknesses and checking for taboos. Once the deck is processed,\n -- passes to loadCards to actually spawn the defined deck.\n ---@param deck table ArkhamImportDeck\n ---@param playerColor string Color name of the player mat to place this deck on (e.g. \"Red\")\n ---@param loadNewest boolean Whether the newest version of this deck should be loaded\n ---@param loadInvestigators boolean Whether investigator cards should be loaded as part of this deck\n ---@param callback function Callback which will be sent the results of this load.\n --- Parameters to the callback will be:\n --- slots table A map of card ID to count in the deck\n --- investigatorCode String. ID of the investigator in this deck\n --- bondedList A table of cardID keys to meaningless values. Card IDs in this list were\n --- added from a parent bonded card.\n --- customizations table The decoded table of customization upgrades in this deck\n --- playerColor String. Color this deck is being loaded for\n internal.onDeckResult = function(deck, playerColor, loadNewest, loadInvestigators, callback)\n -- Load the next deck in the upgrade path if the option is enabled\n if (loadNewest and deck.next_deck ~= nil and deck.next_deck ~= \"\") then\n buildDeck(playerColor, deck.next_deck)\n return\n end\n\n internal.maybePrint(table.concat({ \"Found decklist: \", deck.name }), playerColor)\n\n -- Initialize deck slot table and perform common transformations. The order of these should not\n -- be changed, as later steps may act on cards added in each. For example, a random weakness or\n -- investigator may have bonded cards or taboo entries, and should be present\n local slots = deck.slots\n internal.maybeDrawRandomWeakness(slots, playerColor)\n\n -- handles alternative investigators (parallel, promo or revised art)\n local loadAltInvestigator = \"normal\"\n if loadInvestigators then\n loadAltInvestigator = internal.addInvestigatorCards(deck, slots)\n end\n\n internal.maybeModifyDeckFromDescription(slots, deck.description_md, playerColor)\n internal.maybeAddSummonedServitor(slots)\n internal.maybeAddOnTheMend(slots, playerColor)\n internal.maybeAddRealityAcidReference(slots)\n local bondList = internal.extractBondedCards(slots)\n internal.checkTaboos(deck.taboo_id, slots, playerColor)\n internal.maybeAddUpgradeSheets(slots)\n\n -- get upgrades for customizable cards\n local customizations = {}\n if deck.meta then\n customizations = JSON.decode(deck.meta)\n end\n\n callback(slots, deck.investigator_code, bondList, customizations, playerColor, loadAltInvestigator)\n end\n\n -- Checks to see if the slot list includes the random weakness ID. If it does,\n -- removes it from the deck and replaces it with the ID of a random basic weakness provided by the\n -- all cards bag\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n --- of those cards which will be spawned\n ---@param playerColor string Color of the player this deck is being loaded for. Used for broadcast\n --- if a weakness is added.\n internal.maybeDrawRandomWeakness = function(slots, playerColor)\n local randomWeaknessAmount = slots[RANDOM_WEAKNESS_ID] or 0\n slots[RANDOM_WEAKNESS_ID] = nil\n\n if randomWeaknessAmount ~= 0 then\n for i=1, randomWeaknessAmount do\n local weaknessId = allCardsBagApi.getRandomWeaknessId()\n slots[weaknessId] = (slots[weaknessId] or 0) + 1\n end\n internal.maybePrint(\"Added \" .. randomWeaknessAmount .. \" random basic weakness(es) to deck\", playerColor)\n end\n end\n\n -- Adds both the investigator (XXXXX) and minicard (XXXXX-m) slots with one copy each\n ---@param deck table The processed ArkhamDB deck response\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the\n --- number of those cards which will be spawned\n ---@return string: Contains the name of the art that should be loaded (\"normal\", \"promo\" or \"revised\")\n internal.addInvestigatorCards = function(deck, slots)\n local investigatorId = deck.investigator_code\n slots[investigatorId .. \"-m\"] = 1\n local deckMeta = JSON.decode(deck.meta)\n\n -- handling alternative investigator art and parallel investigators\n local loadAltInvestigator = \"normal\"\n if deckMeta ~= nil then\n local altFrontId = tonumber(deckMeta.alternate_front) or 0\n local altBackId = tonumber(deckMeta.alternate_back) or 0\n local altArt = { front = \"normal\", back = \"normal\" }\n\n -- translating front ID\n if altFrontId \u003e 90000 and altFrontId \u003c 90100 then\n altArt.front = \"parallel\"\n elseif altFrontId \u003e 01500 and altFrontId \u003c 01506 then\n altArt.front = \"revised\"\n elseif altFrontId \u003e 98000 then\n altArt.front = \"promo\"\n end\n\n -- translating back ID\n if altBackId \u003e 90000 and altBackId \u003c 90100 then\n altArt.back = \"parallel\"\n elseif altBackId \u003e 01500 and altBackId \u003c 01506 then\n altArt.back = \"revised\"\n elseif altBackId \u003e 98000 then\n altArt.back = \"promo\"\n end\n\n -- updating investigatorID based on alt investigator selection\n -- precedence: parallel \u003e promo \u003e revised\n if altArt.front == \"parallel\" then\n if altArt.back == \"parallel\" then\n investigatorId = investigatorId .. \"-p\"\n else\n investigatorId = investigatorId .. \"-pf\"\n end\n elseif altArt.back == \"parallel\" then\n investigatorId = investigatorId .. \"-pb\"\n elseif altArt.front == \"promo\" or altArt.back == \"promo\" then\n loadAltInvestigator = \"promo\"\n elseif altArt.front == \"revised\" or altArt.back == \"revised\" then\n loadAltInvestigator = \"revised\"\n end\n end\n slots[investigatorId] = 1\n deck.investigator_code = investigatorId\n return loadAltInvestigator\n end\n\n -- Process the card list looking for the customizable cards, and add their upgrade sheets if needed\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n internal.maybeAddUpgradeSheets = function(slots)\n for cardId, _ in pairs(slots) do\n -- upgrade sheets for customizable cards\n local upgradesheet = allCardsBagApi.getCardById(cardId .. \"-c\")\n if upgradesheet ~= nil then\n slots[cardId .. \"-c\"] = 1\n end\n end\n end\n\n -- Process the card list looking for the Summoned Servitor, and add its minicard to the list if\n -- needed\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n internal.maybeAddSummonedServitor = function(slots)\n if slots[\"09080\"] ~= nil then\n slots[\"09080-m\"] = 1\n end\n end\n\n -- On the Mend should have 1-per-investigator copies set aside, but ArkhamDB always sends 1. Update\n -- the count based on the investigator count\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n ---@param playerColor string Color of the player this deck is being loaded for. Used for broadcast if an error occurs\n internal.maybeAddOnTheMend = function(slots, playerColor)\n if slots[\"09006\"] ~= nil then\n local investigatorCount = playAreaApi.getInvestigatorCount()\n if investigatorCount ~= nil then\n slots[\"09006\"] = investigatorCount\n else\n internal.maybePrint(\"Something went wrong with the load, adding 4 copies of On the Mend\", playerColor)\n slots[\"09006\"] = 4\n end\n end\n end\n\n -- Process the card list looking for Reality Acid and adds the reference sheet when needed\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n internal.maybeAddRealityAcidReference = function(slots)\n if slots[\"89004\"] ~= nil then\n slots[\"89005\"] = 1\n end\n end\n\n -- Processes the deck description from ArkhamDB and modifies the slot list accordingly\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n ---@param description string The deck desription from ArkhamDB\n internal.maybeModifyDeckFromDescription = function(slots, description, playerColor)\n -- check for import instructions\n local pos = string.find(description, \"++SCED import instructions++\")\n if not pos then return end\n\n -- remove everything before instructions\n local tempStr = string.sub(description, pos)\n\n -- parse each line in instructions\n for line in tempStr:gmatch(\"([^\\n]+)\") do\n -- remove dashes at the start\n line = line:gsub(\"%- \", \"\")\n\n -- remove spaces\n line = line:gsub(\"%s\", \"\")\n\n -- remove balanced brackets\n line = line:gsub(\"%b()\", \"\")\n line = line:gsub(\"%b[]\", \"\")\n\n -- get instructor\n local instructor = \"\"\n for word in line:gmatch(\"%a+:\") do\n instructor = word\n break\n end\n\n -- go to the next line if no valid instructor found\n if instructor ~= \"add:\" and instructor ~= \"remove:\" then\n goto nextLine\n end\n\n -- remove instructor from line\n line = line:gsub(instructor, \"\")\n\n -- evaluate instructions\n for str in line:gmatch(\"([^,]+)\") do\n if instructor == \"add:\" then\n slots[str] = (slots[str] or 0) + 1\n elseif instructor == \"remove:\" then\n if slots[str] == nil then\n internal.maybePrint(\"Tried to remove card ID \" .. str .. \", but didn't find card in deck.\", playerColor)\n else\n slots[str] = math.max(slots[str] - 1, 0)\n\n -- fully remove cards that have a quantity of 0\n if slots[str] == 0 then\n slots[str] = nil\n\n -- also remove related minicard\n slots[str .. \"-m\"] = nil\n end\n end\n end\n end\n\n -- jump mark at the end of the loop\n ::nextLine::\n end\n end\n\n -- Process the slot list and looks for any cards which are bonded to those in the deck. Adds those cards to the slot list.\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned\n internal.extractBondedCards = function(slots)\n -- Create a list of bonded cards first so we don't modify slots while iterating\n local bondedCards = { }\n local bondedList = { }\n for cardId, cardCount in pairs(slots) do\n local card = allCardsBagApi.getCardById(cardId)\n if (card ~= nil and card.metadata.bonded ~= nil) then\n for _, bond in ipairs(card.metadata.bonded) do\n -- add a bonded card for each copy of the parent card (except for Pendant of the Queen)\n if bond.id == \"06022\" then\n bondedCards[bond.id] = bond.count\n else\n bondedCards[bond.id] = bond.count * cardCount\n end\n -- We need to know which cards are bonded to determine their position, remember them\n bondedList[bond.id] = true\n -- Also adding taboo versions of bonded cards to the list\n bondedList[bond.id .. \"-t\"] = true\n end\n end\n end\n -- Add any bonded cards to the main slots list\n for bondedId, bondedCount in pairs(bondedCards) do\n slots[bondedId] = bondedCount\n end\n\n return bondedList\n end\n\n -- Check the deck for cards on its taboo list. If they're found, replace the entry in the slot with the Taboo id (i.e. \"XXXX\" becomes \"XXXX-t\")\n ---@param tabooId string The deck's taboo ID, taken from the deck response taboo_id field. May be nil, indicating that no taboo list should be used\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned\n internal.checkTaboos = function(tabooId, slots, playerColor)\n if tabooId then\n for cardId, _ in pairs(tabooList[tabooId].cards) do\n if slots[cardId] ~= nil then\n -- Make sure there's a taboo version of the card before we replace it\n -- SCED only maintains the most recent taboo cards. If a deck is using\n -- an older taboo list it's possible the card isn't a taboo any more\n local tabooCard = allCardsBagApi.getCardById(cardId .. \"-t\")\n if tabooCard == nil then\n local basicCard = allCardsBagApi.getCardById(cardId)\n internal.maybePrint(\"Taboo version for \" .. basicCard.data.Nickname .. \" is not available. Using standard version\", playerColor)\n else\n slots[cardId .. \"-t\"] = slots[cardId]\n slots[cardId] = nil\n end\n end\n end\n end\n end\n\n internal.maybePrint = function(message, playerColor)\n if playerColor ~= \"None\" then\n printToAll(message, playerColor)\n end\n end\n\n -- Gets the ArkhamDB config info from the configuration object.\n ---@return table: configuration data\n internal.getConfiguration = function()\n local configuration = getObjectsWithTag(\"import_configuration_provider\")[1].getTable(\"configuration\")\n printPriority = configuration.priority\n return configuration\n end\n\n internal.fixUtf16String = function(str)\n return str:gsub(\"\\\\u(%w%w%w%w)\", function(match)\n return string.char(tonumber(match, 16))\n end)\n end\n\n Request = {\n is_done = false,\n is_successful = false\n }\n\n -- Creates a new instance of a Request. Should not be directly called. Instead use Request.start() and Request.deferred().\n ---@param uri table\n ---@param configure fun(request, status)\n ---@return Request\n function Request:new(uri, configure)\n local this = {}\n\n setmetatable(this, self)\n self.__index = self\n\n if type(uri) == \"table\" then\n uri = table.concat(uri, \"/\")\n end\n\n this.uri = uri\n WebRequest.get(uri, function(status) configure(this, status) end)\n\n return this\n end\n\n -- Creates a new request. on_success should set the request's is_done, is_successful, and content variables.\n -- Deferred should be used when you don't want to set is_done immediately (such as if you want to wait for another request to finish)\n ---@param uri table\n ---@param on_success fun(request, status, vararg)\n ---@param on_error fun(status)|nil\n ---@return Request\n function Request.deferred(uri, on_success, on_error, ...)\n local parameters = table.pack(...)\n return Request:new(uri, function(request, status)\n if (status.is_done) then\n if (status.is_error) then\n request.error_message = on_error and on_error(status, table.unpack(parameters)) or status.error\n request.is_successful = false\n request.is_done = true\n else\n on_success(request, status)\n end\n end\n end)\n end\n\n -- Creates a new request. on_success should return whether the resultant data is as expected, and the processed content of the request.\n ---@param uri table\n ---@param on_success fun(status, vararg): boolean, any\n ---@param on_error nil|fun(status, vararg): string\n ---@vararg any\n ---@return Request\n function Request.start(uri, on_success, on_error, ...)\n local parameters = table.pack(...)\n return Request.deferred(uri, function(request, status)\n local result, message = on_success(status, table.unpack(parameters))\n if not result then request.error_message = message else request.content = message end\n request.is_successful = result\n request.is_done = true\n end, on_error, table.unpack(parameters))\n end\n\n ---@param requests Request[]\n ---@param on_success fun(content: any, vararg: any)\n ---@param on_error fun(requests: Request, vararg: any)|nil\n ---@vararg any\n function Request.with_all(requests, on_success, on_error, ...)\n local parameters = table.pack(...)\n\n Wait.condition(function()\n local results = {}\n local errors = {}\n\n for _, request in ipairs(requests) do\n if request.is_successful then\n table.insert(results, request.content)\n else\n table.insert(errors, request)\n end\n end\n\n if (#errors \u003c= 0) then\n on_success(results, table.unpack(parameters))\n elseif on_error == nil then\n for _, request in ipairs(errors) do\n internal.maybePrint(table.concat({ \"[ERROR]\", request.uri, \":\", request.error_message }))\n end\n else\n on_error(requests, table.unpack(parameters))\n end\n end, function()\n for _, request in ipairs(requests) do\n if not request.is_done then return false end\n end\n return true\n end)\n end\n\n function Request:with(callback, ...)\n local arguments = table.pack(...)\n Wait.condition(function()\n if self.is_successful then\n callback(self.content, table.unpack(arguments))\n end\n end, function() return self.is_done\n end)\n end\n\n return ArkhamDb\nend\nend)\n__bundle_register(\"arkhamdb/DeckImporterMain\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"arkhamdb/DeckImporterUi\")\nrequire(\"playercards/PlayerCardSpawner\")\n\nlocal allCardsBagApi = require(\"playercards/AllCardsBagApi\")\nlocal arkhamDb = require(\"arkhamdb/ArkhamDb\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal zones = require(\"playermat/Zones\")\n\nlocal startsInPlayCount = 0\n\nfunction onLoad(script_state)\n initializeUi(JSON.decode(script_state))\n math.randomseed(os.time())\n arkhamDb.initialize()\nend\n\nfunction onSave() return JSON.encode(getUiState()) end\n\n-- Returns the zone name where the specified card should be placed, based on its metadata.\n---@param cardMetadata table Contains card metadata\n---@return string Zone Name of the zone such as \"Deck\", \"SetAside1\", etc.\n-- See Zones object documentation for a list of valid zones.\nfunction getDefaultCardZone(cardMetadata, bondedList)\n if (cardMetadata.id == \"09080-m\") then -- Have to check the Servitor before other minicards\n return \"SetAside6\"\n elseif (cardMetadata.id == \"09006\") then -- On The Mend is set aside\n return \"SetAside2\"\n elseif bondedList[cardMetadata.id] then\n return \"SetAside2\"\n elseif cardMetadata.type == \"Investigator\" then\n return \"Investigator\"\n elseif cardMetadata.type == \"Minicard\" then\n return \"Minicard\"\n elseif cardMetadata.type == \"UpgradeSheet\" then\n return \"SetAside4\"\n elseif cardMetadata.startsInPlay then\n return startsInPlayTracker()\n elseif cardMetadata.permanent then\n return \"SetAside1\"\n -- SetAside3 is used for Ancestral Knowledge / Underworld Market\n else\n return \"Deck\"\n end\nend\n\nfunction startsInPlayTracker()\n startsInPlayCount = startsInPlayCount + 1\n if startsInPlayCount \u003e 6 then\n broadcastToAll(\"Card that should start in play was placed with permanents because no blank slots remained\")\n return \"SetAside1\"\n else\n return \"Blank\" .. startsInPlayCount\n end\nend\n\nfunction buildDeck(playerColor, deckId)\n local uiState = getUiState()\n arkhamDb.getDecklist(\n playerColor,\n deckId,\n uiState.privateDeck,\n uiState.loadNewest,\n uiState.investigators,\n loadCards)\nend\n\n-- Process the slot list, which defines the card Ids and counts of cards to load. Spawn those cards\n-- at the appropriate zones and report an error to the user if any could not be loaded.\n-- This is a callback function which handles the results of ArkhamDb.getDecklist()\n-- This method uses an encapsulated coroutine with yields to make the card spawning cleaner.\n--\n---@param slots table Key-Value table of cardId:count. cardId is the ArkhamDB ID of the card to spawn,\n-- and count is the number which should be spawned\n---@param investigatorId string ArkhamDB ID (code) for this deck's investigator.\n-- Investigator cards should already be added to the slots list if they\n-- should be spawned, but this value is separate to check for special\n-- handling for certain investigators\n---@param bondedList table A table of cardID keys to meaningless values. Card IDs in this list were added\n-- from a parent bonded card.\n---@param customizations table ArkhamDB data for customizations on customizable cards\n---@param playerColor string Color name of the player mat to place this deck on (e.g. \"Red\")\n---@param loadAltInvestigator string Contains the name of alternative art for the investigator (\"normal\", \"revised\" or \"promo\")\nfunction loadCards(slots, investigatorId, bondedList, customizations, playerColor, loadAltInvestigator)\n function coinside()\n local cardsToSpawn = {}\n\n -- reset the startsInPlayCount\n startsInPlayCount = 0\n for cardId, cardCount in pairs(slots) do\n local card = allCardsBagApi.getCardById(cardId)\n if card ~= nil then\n local cardZone = getDefaultCardZone(card.metadata, bondedList)\n for i = 1, cardCount do\n table.insert(cardsToSpawn, { data = card.data, metadata = card.metadata, zone = cardZone })\n end\n\n slots[cardId] = 0\n end\n end\n\n handleAncestralKnowledge(cardsToSpawn)\n handleUnderworldMarket(cardsToSpawn, playerColor)\n handleHunchDeck(investigatorId, cardsToSpawn, bondedList, playerColor)\n handleSpiritDeck(investigatorId, cardsToSpawn, playerColor, customizations)\n handleCustomizableUpgrades(cardsToSpawn, customizations)\n handlePeteSignatureAssets(investigatorId, cardsToSpawn)\n\n -- Split the card list into separate lists for each zone\n local zoneDecks = buildZoneLists(cardsToSpawn)\n -- Spawn the list for each zone\n for zone, zoneCards in pairs(zoneDecks) do\n local deckPos = zones.getZonePosition(playerColor, zone):setAt(\"y\", 3)\n local deckRot = zones.getDefaultCardRotation(playerColor, zone)\n\n local callback = nil\n -- If cards are spread too close together TTS groups them weirdly, selecting multiples\n -- when hovering over a single card. This distance is the minimum to avoid that\n local spreadDistance = 1.15\n if (zone == \"SetAside4\") then\n -- SetAside4 is reserved for customization cards, and we want them spread on the table\n -- so their checkboxes are visible\n -- TO-DO: take into account that spreading will make multiple rows\n -- (this is affected by the user's local settings!)\n if (playerColor == \"White\") then\n deckPos.z = deckPos.z + (#zoneCards - 1) * spreadDistance\n elseif (playerColor == \"Green\") then\n deckPos.x = deckPos.x + (#zoneCards - 1) * spreadDistance\n end\n callback = function(deck) deck.spread(spreadDistance) end\n elseif zone == \"Deck\" then\n callback = function(deck) deckSpawned(deck, playerColor) end\n elseif zone == \"Investigator\" or zone == \"Minicard\" then\n callback = function(card) loadAltArt(card, loadAltInvestigator) end\n end\n Spawner.spawnCards(zoneCards, deckPos, deckRot, true, callback)\n coroutine.yield(0)\n end\n\n -- Look for any cards which haven't been loaded\n local hadError = false\n for cardId, remainingCount in pairs(slots) do\n if remainingCount \u003e 0 then\n hadError = true\n arkhamDb.logCardNotFound(cardId, playerColor)\n end\n end\n if (not hadError) then\n printToAll(\"Deck loaded successfully!\", playerColor)\n end\n return 1\n end\n\n startLuaCoroutine(self, \"coinside\")\nend\n\n-- Callback handler for the main deck spawning. Looks for cards which should start in hand, and\n-- draws them for the appropriate player.\n---@param deck tts__Object Callback-provided spawned deck object\n---@param playerColor string Color of the player to draw the cards to\nfunction deckSpawned(deck, playerColor)\n local player = Player[playmatApi.getPlayerColor(playerColor)]\n local handPos = player.getHandTransform(1).position -- Only one hand zone per player\n local deckCards = deck.getData().ContainedObjects\n\n -- Process in reverse order so taking cards out doesn't upset the indexing\n for i = #deckCards, 1, -1 do\n local cardMetadata = JSON.decode(deckCards[i].GMNotes) or { }\n if cardMetadata.startsInHand then\n deck.takeObject({ index = i - 1, position = handPos, flip = true, smooth = true})\n end\n end\n\n -- add the \"PlayerCard\" tag to the deck\n if deck and deck.type == \"Deck\" and deck.getQuantity() \u003e 1 then\n deck.addTag(\"PlayerCard\")\n end\nend\n\n-- Converts the Raven Quill's selections from card IDs to card names. This could be more elegant\n-- but the inputs are very static so we're using some brute force.\n---@param selectionString string provided by ArkhamDB, indicates the customization selections\n-- Should be either a single card ID or two separated by a ^ (e.g. XXXXX^YYYYY)\nfunction convertRavenQuillSelections(selectionString)\n if (string.len(selectionString) == 5) then\n return getCardName(selectionString)\n elseif (string.len(selectionString) == 11) then\n return getCardName(string.sub(selectionString, 1, 5)) .. \", \" .. getCardName(string.sub(selectionString, 7))\n end\nend\n\n-- Converts Grizzled's selections from a single string with \"^\".\n---@param selectionString string provided by ArkhamDB, indicates the customization selections\n-- Should be two Traits separated by a ^ (e.g. XXXXX^YYYYY)\nfunction convertGrizzledSelections(selectionString)\n return selectionString:gsub(\"%^\", \", \")\nend\n\n-- Returns the simple name of a card given its ID. This will find the card and strip any trailing\n-- SCED-specific suffixes such as (Taboo) or (Level)\nfunction getCardName(cardId)\n local card = allCardsBagApi.getCardById(cardId)\n if (card ~= nil) then\n local name = card.data.Nickname\n if (string.find(name, \" %(\")) then\n return string.sub(name, 1, string.find(name, \" %(\") - 1)\n else\n return name\n end\n end\nend\n\n-- Split a single list of cards into a separate table of lists, keyed by the zone\n---@param cards table Table of {cardData, cardMetadata, zone}\n---@return table ZoneNames Table with zoneName as index: {zoneName=card list}\nfunction buildZoneLists(cards)\n local zoneList = {}\n for _, card in ipairs(cards) do\n if zoneList[card.zone] == nil then\n zoneList[card.zone] = {}\n end\n table.insert(zoneList[card.zone], card)\n end\n\n return zoneList\nend\n\n-- Check to see if the deck list has Ancestral Knowledge. If it does, move 5 random skills to SetAside3\n---@param cardList table Deck list being created\nfunction handleAncestralKnowledge(cardList)\n local hasAncestralKnowledge = false\n local skillList = {}\n -- Have to process the entire list to check for Ancestral Knowledge and get all possible skills, so do both in one pass\n for i, card in ipairs(cardList) do\n if card.metadata.id == \"07303\" then\n hasAncestralKnowledge = true\n card.zone = \"SetAside3\"\n elseif (card.metadata.type == \"Skill\"\n and card.zone == \"Deck\"\n and not card.metadata.weakness) then\n table.insert(skillList, i)\n end\n end\n\n if not hasAncestralKnowledge then return end\n\n for i = 1, 5 do\n -- Move 5 random skills to SetAside3\n local skillListIndex = math.random(#skillList)\n cardList[skillList[skillListIndex]].zone = \"UnderSetAside3\"\n table.remove(skillList, skillListIndex)\n end\nend\n\n-- Check for and handle Underworld Market by moving all Illicit cards to UnderSetAside3\n---@param cardList table Deck list being created\n---@param playerColor string Color this deck is being loaded for\nfunction handleUnderworldMarket(cardList, playerColor)\n local hasMarket = false\n local illicitList = {}\n -- Process the entire list to check for Underworld Market and get all possible Illicit cards, doing both in one pass\n for i, card in ipairs(cardList) do\n if card.metadata.id == \"09077\" then\n -- Underworld Market found\n hasMarket = true\n card.zone = \"SetAside3\"\n elseif card.metadata.traits ~= nil and string.find(card.metadata.traits, \"Illicit\", 1, true) and card.zone == \"Deck\" then\n table.insert(illicitList, i)\n end\n end\n\n if not hasMarket then return end\n\n if #illicitList \u003c 10 then\n printToAll(\"Only \" .. #illicitList .. \" Illicit cards in your deck, you can't trigger Underworld Market's ability.\", playerColor)\n else\n -- Process cards to move them to the market deck. This is done in reverse\n -- order because the sorting needs to be reversed (deck sorts for face down)\n -- Performance here may be an issue, as table.remove() is an O(n) operation\n -- which makes the full shift O(n^2). But keep it simple unless it becomes\n -- a problem\n for i = #illicitList, 1, -1 do\n local moving = cardList[illicitList[i]]\n moving.zone = \"UnderSetAside3\"\n table.remove(cardList, illicitList[i])\n table.insert(cardList, moving)\n end\n\n if #illicitList \u003e 10 then\n printToAll(\"Moved all \" .. #illicitList .. \" Illicit cards to the Market deck, reduce it to 10\", playerColor)\n else\n printToAll(\"Built the Market deck\", playerColor)\n end\n end\nend\n\n-- If the investigator is Joe Diamond, extract all Insight events to SetAside5 to build the Hunch Deck\n---@param investigatorId string ID for the deck's investigator card. Passed separately because the\n--- investigator may not be included in the cardList\n---@param cardList table Deck list being created\n---@param playerColor string Color this deck is being loaded for\nfunction handleHunchDeck(investigatorId, cardList, bondedList, playerColor)\n if investigatorId ~= \"05002\" then return end\n\n local insightList = {}\n for i, card in ipairs(cardList) do\n if (card.metadata.type == \"Event\"\n and card.metadata.traits ~= nil\n and string.match(card.metadata.traits, \"Insight\")\n and bondedList[card.metadata.id] == nil) then\n table.insert(insightList, i)\n end\n end\n -- Process insights to move them to the hunch deck. This is done in reverse\n -- order because the sorting needs to be reversed (deck sorts for face down)\n -- Performance here may be an issue, as table.remove() is an O(n) operation\n -- which makes the full shift O(n^2). But keep it simple unless it becomes\n -- a problem\n for i = #insightList, 1, -1 do\n local moving = cardList[insightList[i]]\n moving.zone = \"SetAside5\"\n table.remove(cardList, insightList[i])\n table.insert(cardList, moving)\n end\n\n if #insightList \u003c 11 then\n printToAll(\"Joe's hunch deck must have 11 cards but the deck only has \" .. #insightList .. \" Insight events.\", playerColor)\n elseif #insightList \u003e 11 then\n printToAll(\"Moved all \" .. #insightList .. \" Insight events to the hunch deck, reduce it to 11.\", playerColor)\n else\n printToAll(\"Built Joe's hunch deck\", playerColor)\n end\nend\n\n-- If the investigator is Parallel Jim Culver, extract all Ally assets to SetAside5 to build the Spirit Deck\n---@param investigatorId string ID for the deck's investigator card. Passed separately because the\n--- investigator may not be included in the cardList\n---@param cardList table Deck list being created\n---@param playerColor string Color this deck is being loaded for\n---@param customizations table Additional deck information\nfunction handleSpiritDeck(investigatorId, cardList, playerColor, customizations)\n if investigatorId ~= \"02004-p\" and investigatorId ~= \"02004-pb\" then return end\n\n local spiritList = {}\n if customizations[\"extra_deck\"] then\n -- split by \",\"\n for str in string.gmatch(customizations[\"extra_deck\"], \"([^,]+)\") do\n local card = allCardsBagApi.getCardById(str)\n if card ~= nil then\n table.insert(cardList, { data = card.data, metadata = card.metadata, zone = \"SetAside5\" })\n table.insert(spiritList, str)\n end\n end\n else\n for i, card in ipairs(cardList) do\n if card.metadata.id == \"90053\" or (\n card.metadata.type == \"Asset\"\n and card.metadata.traits ~= nil\n and string.match(card.metadata.traits, \"Ally\")\n and card.metadata.level ~= nil\n and card.metadata.level \u003c 3) then\n table.insert(spiritList, i)\n end\n end\n\n -- Process allies to move them to the spirit deck. This is done in reverse\n -- order because the sorting needs to be reversed (deck sorts for face down)\n -- Performance here may be an issue, as table.remove() is an O(n) operation\n -- which makes the full shift O(n^2). But keep it simple unless it becomes\n -- a problem\n for i = #spiritList, 1, -1 do\n local moving = cardList[spiritList[i]]\n moving.zone = \"SetAside5\"\n table.remove(cardList, spiritList[i])\n table.insert(cardList, moving)\n end\n end\n\n if #spiritList \u003c 10 then\n printToAll(\"Jim's spirit deck must have 9 Ally assets but the deck only has \" .. (#spiritList - 1) .. \" Ally assets.\", playerColor)\n elseif #spiritList \u003e 11 then\n printToAll(\"Moved all \" .. (#spiritList - 1) .. \" Ally assets to the spirit deck, reduce it to 10 (including Vengeful Shade).\", playerColor)\n else\n printToAll(\"Built Jim's spirit deck\", playerColor)\n end\nend\n\n-- For any customization upgrade cards in the card list, process the metadata from the deck to\n-- set the save state to show the correct checkboxes/text field values\n---@param cardList table Deck list being created\n---@param customizations table ArkhamDB data for customizations on customizable cards\nfunction handleCustomizableUpgrades(cardList, customizations)\n for _, card in ipairs(cardList) do\n if card.metadata.type == \"UpgradeSheet\" then\n local baseId = string.sub(card.metadata.id, 1, 5)\n local upgrades = customizations[\"cus_\" .. baseId]\n\n if upgrades ~= nil then\n -- initialize tables\n -- markedBoxes: contains the amount of markedBoxes (left to right) per row (starting at row 1)\n -- inputValues: contains the amount of inputValues per row (starting at row 0)\n local selectedUpgrades = { }\n local index_xp = {}\n\n -- get the index and xp values (looks like this: X|X,X|X, ..)\n -- input string from ArkhamDB is split by \",\"\n for str in string.gmatch(customizations[\"cus_\" .. baseId], \"([^,]+)\") do\n table.insert(index_xp, str)\n end\n\n -- split each pair and assign it to the proper position in markedBoxes\n for _, entry in ipairs(index_xp) do\n -- counter increments from 1 to 3 and indicates the part of the string we are on\n -- usually: 1 = row, 2 = amount of check boxes, 3 = entry in inputfield\n local counter = 0\n local row = 0\n\n -- parsing the string for each row\n for str in entry:gmatch(\"([^|]+)\") do\n counter = counter + 1\n\n if counter == 1 then\n row = tonumber(str) + 1\n elseif counter == 2 then\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n end\n selectedUpgrades[row].xp = tonumber(str)\n elseif counter == 3 and str ~= \"\" then\n if baseId == \"09042\" then\n selectedUpgrades[row].text = convertRavenQuillSelections(str)\n elseif baseId == \"09101\" then\n selectedUpgrades[row].text = convertGrizzledSelections(str)\n elseif baseId == \"09079\" then -- Living Ink skill selection\n -- All skills, regardless of row, are placed in upgrade slot 1 as a comma-delimited list\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n if selectedUpgrades[1].text == nil then\n selectedUpgrades[1].text = str\n else\n selectedUpgrades[1].text = selectedUpgrades[1].text .. \",\" .. str\n end\n else\n selectedUpgrades[row].text = str\n end\n end\n end\n end\n\n -- write the loaded values to the save_data of the sheets\n card.data[\"LuaScriptState\"] = JSON.encode({ selections = selectedUpgrades })\n end\n end\n end\nend\n\n-- Handles cards that start in play under specific conditions for Ashcan Pete (Regular Pete - Duke, Parallel Pete - Guitar)\n---@param investigatorId string ID for the deck's investigator card. Passed separately because the\n--- investigator may not be included in the cardList\n---@param cardList table Deck list being created\nfunction handlePeteSignatureAssets(investigatorId, cardList)\n if investigatorId == \"02005\" or investigatorId == \"02005-pb\" then -- regular Pete's front\n for i, card in ipairs(cardList) do\n if card.metadata.id == \"02014\" then -- Duke\n card.zone = startsInPlayTracker()\n end\n end\n elseif investigatorId == \"02005-p\" or investigatorId == \"02005-pf\" then -- parallel Pete's front\n for i, card in ipairs(cardList) do\n if card.metadata.id == \"90047\" then -- Pete's Guitar\n card.zone = startsInPlayTracker()\n end\n end\n end\nend\n\n-- Callback function for investigator cards and minicards to set the correct state for alt art\n---@param card tts__Object Card which needs to be set the state for\n---@param loadAltInvestigator string Contains the name of alternative art for the investigator (\"normal\", \"revised\" or \"promo\")\nfunction loadAltArt(card, loadAltInvestigator)\n -- states are set up this way:\n -- 1 - normal, 2 - revised/promo, 3 - promo (if 2 is revised)\n -- This means we can always load the 2nd state for revised and just get the last state for promo\n if loadAltInvestigator == \"normal\" then\n return\n elseif loadAltInvestigator == \"revised\" then\n card.setState(2)\n elseif loadAltInvestigator == \"promo\" then\n local states = card.getStates()\n card.setState(#states)\n end\nend\nend)\n__bundle_register(\"arkhamdb/DeckImporterUi\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal allCardsBagApi = require(\"playercards/AllCardsBagApi\")\n\nlocal INPUT_FIELD_HEIGHT = 340\nlocal INPUT_FIELD_WIDTH = 1500\nlocal FIELD_COLOR = { 0.9, 0.7, 0.5 }\n\nlocal PRIVATE_TOGGLE_LABELS = {}\nPRIVATE_TOGGLE_LABELS[true] = \"Private\"\nPRIVATE_TOGGLE_LABELS[false] = \"Published\"\n\nlocal UPGRADED_TOGGLE_LABELS = {}\nUPGRADED_TOGGLE_LABELS[true] = \"Upgraded\"\nUPGRADED_TOGGLE_LABELS[false] = \"Specific\"\n\nlocal LOAD_INVESTIGATOR_TOGGLE_LABELS = {}\nLOAD_INVESTIGATOR_TOGGLE_LABELS[true] = \"Yes\"\nLOAD_INVESTIGATOR_TOGGLE_LABELS[false] = \"No\"\n\nlocal redDeckId = \"\"\nlocal orangeDeckId = \"\"\nlocal whiteDeckId = \"\"\nlocal greenDeckId = \"\"\n\nlocal privateDeck = true\nlocal loadNewestDeck = true\nlocal loadInvestigators = false\n\n-- Returns a table with the full state of the UI, including options and deck IDs.\n-- This can be used to persist via onSave(), or provide values for a load operation\n---@return uiStateTable uiStateTable Contains data about the current UI state\nfunction getUiState()\n return {\n redDeck = redDeckId,\n orangeDeck = orangeDeckId,\n whiteDeck = whiteDeckId,\n greenDeck = greenDeckId,\n privateDeck = privateDeck,\n loadNewest = loadNewestDeck,\n investigators = loadInvestigators\n }\nend\n\n-- Updates the state of the UI based on the provided table. Any values not provided will be left the same.\n---@param uiStateTable table Table of values to update on importer\nfunction setUiState(uiStateTable)\n self.clearButtons()\n self.clearInputs()\n initializeUi(uiStateTable)\nend\n\n-- Sets up the UI for the deck loader, populating fields from the given save state table decoded from onLoad()\nfunction initializeUi(savedUiState)\n if savedUiState ~= nil then\n redDeckId = savedUiState.redDeck\n orangeDeckId = savedUiState.orangeDeck\n whiteDeckId = savedUiState.whiteDeck\n greenDeckId = savedUiState.greenDeck\n privateDeck = savedUiState.privateDeck\n loadNewestDeck = savedUiState.loadNewest\n loadInvestigators = savedUiState.investigators\n end\n\n makeOptionToggles()\n makeDeckIdFields()\n makeBuildButton()\nend\n\nfunction makeOptionToggles()\n -- common parameters\n local checkbox_parameters = {}\n checkbox_parameters.function_owner = self\n checkbox_parameters.width = INPUT_FIELD_WIDTH\n checkbox_parameters.height = INPUT_FIELD_HEIGHT\n checkbox_parameters.scale = { 0.1, 0.1, 0.1 }\n checkbox_parameters.font_size = 240\n checkbox_parameters.hover_color = { 0.4, 0.6, 0.8 }\n checkbox_parameters.color = FIELD_COLOR\n\n -- public / private deck\n checkbox_parameters.click_function = \"publicPrivateChanged\"\n checkbox_parameters.position = { 0.25, 0.1, -0.102 }\n checkbox_parameters.tooltip = \"Published or private deck?\\n\\nPLEASE USE A PRIVATE DECK IF JUST FOR TTS TO AVOID FLOODING ARKHAMDB PUBLISHED DECK LISTS!\"\n checkbox_parameters.label = PRIVATE_TOGGLE_LABELS[privateDeck]\n self.createButton(checkbox_parameters)\n\n -- load upgraded?\n checkbox_parameters.click_function = \"loadUpgradedChanged\"\n checkbox_parameters.position = { 0.25, 0.1, -0.01 }\n checkbox_parameters.tooltip = \"Load newest upgrade or exact deck?\"\n checkbox_parameters.label = UPGRADED_TOGGLE_LABELS[loadNewestDeck]\n self.createButton(checkbox_parameters)\n\n -- load investigators?\n checkbox_parameters.click_function = \"loadInvestigatorsChanged\"\n checkbox_parameters.position = { 0.25, 0.1, 0.081 }\n checkbox_parameters.tooltip = \"Spawn investigator cards?\"\n checkbox_parameters.label = LOAD_INVESTIGATOR_TOGGLE_LABELS[loadInvestigators]\n self.createButton(checkbox_parameters)\nend\n\n-- Create the four deck ID entry fields\nfunction makeDeckIdFields()\n local input_parameters = {}\n -- Parameters common to all entry fields\n input_parameters.function_owner = self\n input_parameters.scale = { 0.1, 0.1, 0.1 }\n input_parameters.width = INPUT_FIELD_WIDTH\n input_parameters.height = INPUT_FIELD_HEIGHT\n input_parameters.font_size = 320\n input_parameters.tooltip = \"Deck ID from ArkhamDB URL of the deck\\nPublic URL: 'https://arkhamdb.com/decklist/view/101/knowledge-overwhelming-solo-deck-1.0' = '101'\\nPrivate URL: 'https://arkhamdb.com/deck/view/102' = '102'\"\n input_parameters.alignment = 3 -- Center\n input_parameters.color = FIELD_COLOR\n input_parameters.font_color = { 0, 0, 0 }\n input_parameters.validation = 2 -- Integer\n\n -- Green\n input_parameters.input_function = \"greenDeckChanged\"\n input_parameters.position = { -0.166, 0.1, 0.385 }\n input_parameters.value = greenDeckId\n self.createInput(input_parameters)\n -- Red\n input_parameters.input_function = \"redDeckChanged\"\n input_parameters.position = { 0.171, 0.1, 0.385 }\n input_parameters.value = redDeckId\n self.createInput(input_parameters)\n -- White\n input_parameters.input_function = \"whiteDeckChanged\"\n input_parameters.position = { -0.166, 0.1, 0.474 }\n input_parameters.value = whiteDeckId\n self.createInput(input_parameters)\n -- Orange\n input_parameters.input_function = \"orangeDeckChanged\"\n input_parameters.position = { 0.171, 0.1, 0.474 }\n input_parameters.value = orangeDeckId\n self.createInput(input_parameters)\nend\n\n-- Create the Build All button. This is a transparent button which covers the Build All portion of the background graphic\nfunction makeBuildButton()\n local button_parameters = {}\n button_parameters.click_function = \"loadDecks\"\n button_parameters.function_owner = self\n button_parameters.position = { 0, 0.1, 0.71 }\n button_parameters.width = 320\n button_parameters.height = 30\n button_parameters.color = { 0, 0, 0, 0 }\n button_parameters.tooltip = \"Click to build all four decks!\"\n self.createButton(button_parameters)\nend\n\n-- Event handlers for deck ID change\nfunction redDeckChanged(_, _, inputValue) redDeckId = inputValue end\n\nfunction orangeDeckChanged(_, _, inputValue) orangeDeckId = inputValue end\n\nfunction whiteDeckChanged(_, _, inputValue) whiteDeckId = inputValue end\n\nfunction greenDeckChanged(_, _, inputValue) greenDeckId = inputValue end\n\n-- Event handlers for toggle buttons\nfunction publicPrivateChanged()\n privateDeck = not privateDeck\n self.editButton { index = 0, label = PRIVATE_TOGGLE_LABELS[privateDeck] }\nend\n\nfunction loadUpgradedChanged()\n loadNewestDeck = not loadNewestDeck\n self.editButton { index = 1, label = UPGRADED_TOGGLE_LABELS[loadNewestDeck] }\nend\n\nfunction loadInvestigatorsChanged()\n loadInvestigators = not loadInvestigators\n self.editButton { index = 2, label = LOAD_INVESTIGATOR_TOGGLE_LABELS[loadInvestigators] }\nend\n\nfunction loadDecks()\n -- testLoadLotsOfDecks()\n -- Method in DeckImporterMain, visible due to inclusion\n\n local indexReady = allCardsBagApi.isIndexReady()\n if (not indexReady) then\n broadcastToAll(\"Still loading player cards, please try again in a few seconds\", {0.9, 0.2, 0.2})\n return\n end\n if (redDeckId ~= nil and redDeckId ~= \"\") then\n buildDeck(\"Red\", redDeckId)\n end\n if (orangeDeckId ~= nil and orangeDeckId ~= \"\") then\n buildDeck(\"Orange\", orangeDeckId)\n end\n if (whiteDeckId ~= nil and whiteDeckId ~= \"\") then\n buildDeck(\"White\", whiteDeckId)\n end\n if (greenDeckId ~= nil and greenDeckId ~= \"\") then\n buildDeck(\"Green\", greenDeckId)\n end\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"playercards/AllCardsBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local AllCardsBagApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getAllCardsBag()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"AllCardsBag\")\n end\n\n -- Returns a specific card from the bag, based on ArkhamDB ID\n ---@param id table String ID of the card to retrieve\n ---@return table table\n -- If the indexes are still being constructed, an empty table is\n -- returned. Otherwise, a single table with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardById = function(id)\n return getAllCardsBag().call(\"getCardById\", {id = id})\n end\n\n -- Gets a random basic weakness from the bag. Once a given ID has been returned\n -- it will be removed from the list and cannot be selected again until a reload\n -- occurs or the indexes are rebuilt, which will refresh the list to include all\n -- weaknesses.\n ---@return string: ID of the selected weakness.\n AllCardsBagApi.getRandomWeaknessId = function()\n return getAllCardsBag().call(\"getRandomWeaknessId\")\n end\n\n AllCardsBagApi.isIndexReady = function()\n return getAllCardsBag().call(\"isIndexReady\")\n end\n\n -- Called by Hotfix bags when they load. If we are still loading indexes, then\n -- the all cards and hotfix bags are being loaded together, and we can ignore\n -- this call as the hotfix will be included in the initial indexing. If it is\n -- called once indexing is complete it means the hotfix bag has been added\n -- later, and we should rebuild the index to integrate the hotfix bag.\n AllCardsBagApi.rebuildIndexForHotfix = function()\n return getAllCardsBag().call(\"rebuildIndexForHotfix\")\n end\n\n -- Searches the bag for cards which match the given name and returns a list. Note that this is\n -- an O(n) search without index support. It may be slow.\n ---@param name string or string fragment to search for names\n ---@param exact boolean Whether the name match should be exact\n AllCardsBagApi.getCardsByName = function(name, exact)\n return getAllCardsBag().call(\"getCardsByName\", {name = name, exact = exact})\n end\n\n AllCardsBagApi.isBagPresent = function()\n return getAllCardsBag() and true\n end\n\n -- Returns a list of cards from the bag matching a class and level (0 or upgraded)\n ---@param class string class to retrieve (\"Guardian\", \"Seeker\", etc)\n ---@param upgraded boolean true for upgraded cards (Level 1-5), false for Level 0\n ---@return table: If the indexes are still being constructed, returns an empty table.\n -- Otherwise, a list of tables, each with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded)\n return getAllCardsBag().call(\"getCardsByClassAndLevel\", {class = class, upgraded = upgraded})\n end\n\n AllCardsBagApi.getCardsByCycle = function(cycle)\n return getAllCardsBag().call(\"getCardsByCycle\", cycle)\n end\n\n AllCardsBagApi.getUniqueWeaknesses = function()\n return getAllCardsBag().call(\"getUniqueWeaknesses\")\n end\n\n return AllCardsBagApi\nend\nend)\n__bundle_register(\"playercards/PlayerCardSpawner\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Amount to shift for the next card (zShift) or next row of cards (xShift)\n-- Note that the table rotation is weird, and the X axis is vertical while the\n-- Z axis is horizontal\nlocal SPREAD_Z_SHIFT = -2.3\nlocal SPREAD_X_SHIFT = -3.66\n\nSpawner = { }\n\n-- Spawns a list of cards at the given position/rotation. This will separate cards by size -\n-- investigator, standard, and mini, spawning them in that order with larger cards on bottom. If\n-- there are different types, the provided callback will be called once for each type as it spawns\n-- either a card or deck.\n---@param cardList table A list of Player Card data structures (data/metadata)\n---@param pos tts__Vector table where the cards should be spawned (global)\n---@param rot tts__Vector table for the orientation of the spawned cards (global)\n---@param sort boolean True if this list of cards should be sorted before spawning\n---@param callback? function Callback to be called after the card/deck spawns.\nSpawner.spawnCards = function(cardList, pos, rot, sort, callback)\n if (sort) then\n table.sort(cardList, Spawner.cardComparator)\n end\n\n local miniCards = { }\n local standardCards = { }\n local investigatorCards = { }\n\n for _, card in ipairs(cardList) do\n if (card.metadata.type == \"Investigator\") then\n table.insert(investigatorCards, card)\n elseif (card.metadata.type == \"Minicard\") then\n table.insert(miniCards, card)\n else\n table.insert(standardCards, card)\n end\n end\n -- Spawn each of the three types individually. Each Y position shift accounts for the thickness\n -- of the spawned deck\n local position = { x = pos.x, y = pos.y, z = pos.z }\n Spawner.spawn(investigatorCards, position, rot, callback)\n\n position.y = position.y + (#investigatorCards + #standardCards) * 0.07\n Spawner.spawn(standardCards, position, rot, callback)\n\n position.y = position.y + (#standardCards + #miniCards) * 0.07\n Spawner.spawn(miniCards, position, rot, callback)\nend\n\nSpawner.spawnCardSpread = function(cardList, startPos, maxCols, rot, sort, callback)\n if (sort) then\n table.sort(cardList, Spawner.cardComparator)\n end\n\n local position = { x = startPos.x, y = startPos.y, z = startPos.z }\n -- Special handle the first row if we have less than a full single row, but only if there's a\n -- reasonable max column count. Single-row spreads will send a large value for maxCols\n if maxCols \u003c 100 and #cardList \u003c maxCols then\n position.z = startPos.z + ((maxCols - #cardList) / 2 * SPREAD_Z_SHIFT)\n end\n local cardsInRow = 0\n local rows = 0\n for _, card in ipairs(cardList) do\n Spawner.spawn({ card }, position, rot, callback)\n position.z = position.z + SPREAD_Z_SHIFT\n cardsInRow = cardsInRow + 1\n if cardsInRow \u003e= maxCols then\n rows = rows + 1\n local cardsForRow = #cardList - rows * maxCols\n if cardsForRow \u003e maxCols then\n cardsForRow = maxCols\n end\n position.z = startPos.z + ((maxCols - cardsForRow) / 2 * SPREAD_Z_SHIFT)\n position.x = position.x + SPREAD_X_SHIFT\n cardsInRow = 0\n end\n end\nend\n\n-- Spawn a specific list of cards. This method is for internal use and should not be called\n-- directly, use spawnCards instead.\n---@param cardList table A list of Player Card data structures (data/metadata)\n---@param pos table Position where the cards should be spawned (global)\n---@param rot table Rotation for the orientation of the spawned cards (global)\n---@param callback? function callback to be called after the card/deck spawns.\nSpawner.spawn = function(cardList, pos, rot, callback)\n if #cardList == 0 then return end\n\n -- Spawn a single card directly\n if #cardList == 1 then\n -- handle sideways card\n if cardList[1].data.SidewaysCard then\n rot = { rot.x, rot.y - 90, rot.z }\n end\n spawnObjectData({\n data = cardList[1].data,\n position = pos,\n rotation = rot,\n callback_function = callback\n })\n return\n end\n\n -- For multiple cards, construct a deck and spawn that\n local deck = Spawner.buildDeckDataTemplate()\n\n -- Decks won't inherently scale to the cards in them. The card list being spawned should be all\n -- the same type/size by this point, so use the first card to set the size\n deck.Transform = {\n scaleX = cardList[1].data.Transform.scaleX,\n scaleY = 1,\n scaleZ = cardList[1].data.Transform.scaleZ\n }\n\n local sidewaysDeck = true\n for _, spawnCard in ipairs(cardList) do\n Spawner.addCardToDeck(deck, spawnCard.data)\n -- set sidewaysDeck to false if any card is not a sideways card\n sidewaysDeck = (sidewaysDeck and spawnCard.data.SidewaysCard)\n end\n\n -- set the alt view angle for sideways decks\n if sidewaysDeck then\n deck.AltLookAngle = { x = 0, y = 180, z = 90 }\n rot = { rot.x, rot.y - 90, rot.z }\n end\n\n spawnObjectData({\n data = deck,\n position = pos,\n rotation = rot,\n callback_function = callback\n })\nend\n\n-- Inserts a card into the given deck. This does three things:\n-- 1. Add the card's data to ContainedObjects\n-- 2. Add the card's ID (the TTS CardID, not the Arkham ID) to the deck's\n-- ID list. Note that the deck's ID list is \"DeckIDs\" even though it\n-- contains a list of card Ids\n-- 3. Extract the card's CustomDeck table and add it to the deck. The deck's\n-- \"CustomDeck\" field is a list of all CustomDecks used by cards within the\n-- deck, keyed by the DeckID and referencing the custom deck table\n---@param deck table TTS deck data structure to add to\n---@param cardData table Data for the card to be inserted\nSpawner.addCardToDeck = function(deck, cardData)\n for customDeckId, customDeckData in pairs(cardData.CustomDeck) do\n if (deck.CustomDeck[customDeckId] == nil) then\n -- CustomDeck not added to deck yet, add it\n deck.CustomDeck[customDeckId] = customDeckData\n elseif (deck.CustomDeck[customDeckId].FaceURL == customDeckData.FaceURL) then\n -- CustomDeck for this card matches the current one for the deck, do nothing\n else\n -- CustomDeck data conflict\n local newDeckId = nil\n for deckId, customDeck in pairs(deck.CustomDeck) do\n if (customDeckData.FaceURL == customDeck.FaceURL) then\n newDeckId = deckId\n end\n end\n if (newDeckId == nil) then\n -- No non-conflicting custom deck for this card, add a new one\n newDeckId = Spawner.findNextAvailableId(deck.CustomDeck, \"1000\")\n deck.CustomDeck[newDeckId] = customDeckData\n end\n -- Update the card with the new CustomDeck info\n cardData.CardID = newDeckId..string.sub(cardData.CardID, 5)\n cardData.CustomDeck[customDeckId] = nil\n cardData.CustomDeck[newDeckId] = customDeckData\n break\n end\n end\n table.insert(deck.ContainedObjects, cardData)\n table.insert(deck.DeckIDs, cardData.CardID)\nend\n\n-- Create an empty deck data table which can have cards added to it. This\n-- creates a new table on each call without using metatables or previous\n-- definitions because we can't be sure that TTS doesn't modify the structure\n---@return table deck Table containing the minimal TTS deck data structure\nSpawner.buildDeckDataTemplate = function()\n local deck = {}\n deck.Name = \"Deck\"\n\n -- Card data. DeckIDs and CustomDeck entries will be built from the cards\n deck.ContainedObjects = {}\n deck.DeckIDs = {}\n deck.CustomDeck = {}\n\n -- Transform is required, Position and Rotation will be overridden by the spawn call so can be omitted here\n deck.Transform = {\n scaleX = 1,\n scaleY = 1,\n scaleZ = 1,\n }\n\n return deck\nend\n\n-- Returns the first ID which does not exist in the given table, starting at startId and increasing\n---@param objectTable table keyed by strings which are numbers\n---@param startId string possible ID.\n---@return string id \u003e= startId\nSpawner.findNextAvailableId = function(objectTable, startId)\n local id = startId\n while (objectTable[id] ~= nil) do\n id = tostring(tonumber(id) + 1)\n end\n return id\nend\n\n-- Get the PBCN (Permanent/Bonded/Customizable/Normal) value from the given metadata.\n---@return number PBCN 1 for Permanent, 2 for Bonded or 4 for Normal. The actual values are\n-- irrelevant as they provide only grouping and the order between them doesn't matter.\nSpawner.getpbcn = function(metadata)\n if metadata.permanent then\n return 1\n elseif metadata.bonded_to ~= nil then\n return 2\n else -- Normal card\n return 3\n end\nend\n\n-- Comparison function used to sort the cards in a deck. Groups bonded or\n-- permanent cards first, then sorts within theose types by name/subname.\n-- Normal cards will sort in standard alphabetical order, while\n-- permanent/bonded/customizable will be in reverse alphabetical order.\n--\n-- Since cards spawn in the order provided by this comparator, with the first\n-- cards ending up at the bottom of a pile, this ordering will spawn in reverse\n-- alphabetical order. This presents the cards in order for non-face-down\n-- areas, and presents them in order when Searching the face-down deck.\nSpawner.cardComparator = function(card1, card2)\n local pbcn1 = Spawner.getpbcn(card1.metadata)\n local pbcn2 = Spawner.getpbcn(card2.metadata)\n if pbcn1 ~= pbcn2 then\n return pbcn1 \u003e pbcn2\n end\n if pbcn1 == 3 then\n if card1.data.Nickname ~= card2.data.Nickname then\n return card1.data.Nickname \u003c card2.data.Nickname\n end\n return card1.data.Description \u003c card2.data.Description\n else\n if card1.data.Nickname ~= card2.data.Nickname then\n return card1.data.Nickname \u003e card2.data.Nickname\n end\n return card1.data.Description \u003e card2.data.Description\n end\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"playermat/Zones\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Sets up and returns coordinates for all possible spawn zones. Because Lua assigns tables by reference\n-- and there is no built-in function to copy a table this is relatively brute force.\n--\n-- Positions are all relative to the player mat, and most are consistent. The\n-- exception are the SetAside# zones, which are placed to the left of the mat\n-- for White/Green, and the right of the mat for Orange/Red.\n--\n-- Investigator: Investigator card area.\n-- Minicard: Placement for the investigator's minicard, just above the player mat\n-- Deck, Discard: Standard locations for the deck and discard piles.\n-- Blank1: used for assets that start in play (e.g. Duke)\n-- Tarot, Hand1, Hand2, Ally, Blank4, Accessory, Arcane1, Arcane2, Body: Asset slot positions\n-- Threat[1-4]: Threat area slots. Threat[1-3] correspond to the named threat area slots, and Threat4 is the blank threat area slot.\n-- SetAside[1-3]: Column closest to the player mat, with 1 at the top and 3 at the bottom.\n-- SetAside[4-6]: Column farther away from the mat, with 4 at the top and 6 at the bottom.\n-- SetAside1: Permanent cards\n-- SetAside2: Bonded cards\n-- SetAside3: Ancestral Knowledge / Underworld Market\n-- SetAside4: Upgrade sheets for customizable cards\n-- SetAside5: Hunch Deck for Joe Diamond\n-- SetAside6: currently unused\ndo\n local playmatApi = require(\"playermat/PlaymatApi\")\n local Zones = { }\n\n local commonZones = {}\n commonZones[\"Investigator\"] = { -1.177, 0, 0.002 }\n commonZones[\"Deck\"] = { -1.82, 0, 0 }\n commonZones[\"Discard\"] = { -1.82, 0, 0.61 }\n commonZones[\"Ally\"] = { -0.615, 0, 0.024 }\n commonZones[\"Body\"] = { -0.630, 0, 0.553 }\n commonZones[\"Hand1\"] = { 0.215, 0, 0.042 }\n commonZones[\"Hand2\"] = { -0.180, 0, 0.037 }\n commonZones[\"Arcane1\"] = { 0.212, 0, 0.559 }\n commonZones[\"Arcane2\"] = { -0.171, 0, 0.557 }\n commonZones[\"Tarot\"] = { 0.602, 0, 0.033 }\n commonZones[\"Accessory\"] = { 0.602, 0, 0.555 }\n commonZones[\"Blank1\"] = { 1.758, 0, 0.040 }\n commonZones[\"Blank2\"] = { 1.754, 0, 0.563 }\n commonZones[\"Blank3\"] = { 1.371, 0, 0.038 }\n commonZones[\"Blank4\"] = { 1.371, 0, 0.558 }\n commonZones[\"Blank5\"] = { 0.98, 0, 0.035 }\n commonZones[\"Blank6\"] = { 0.977, 0, 0.556 }\n commonZones[\"Threat1\"] = { -0.911, 0, -0.625 }\n commonZones[\"Threat2\"] = { -0.454, 0, -0.625 }\n commonZones[\"Threat3\"] = { 0.002, 0, -0.625 }\n commonZones[\"Threat4\"] = { 0.459, 0, -0.625 }\n\n local zoneData = {}\n zoneData[\"White\"] = {}\n zoneData[\"White\"][\"Investigator\"] = commonZones[\"Investigator\"]\n zoneData[\"White\"][\"Deck\"] = commonZones[\"Deck\"]\n zoneData[\"White\"][\"Discard\"] = commonZones[\"Discard\"]\n zoneData[\"White\"][\"Ally\"] = commonZones[\"Ally\"]\n zoneData[\"White\"][\"Body\"] = commonZones[\"Body\"]\n zoneData[\"White\"][\"Hand1\"] = commonZones[\"Hand1\"]\n zoneData[\"White\"][\"Hand2\"] = commonZones[\"Hand2\"]\n zoneData[\"White\"][\"Arcane1\"] = commonZones[\"Arcane1\"]\n zoneData[\"White\"][\"Arcane2\"] = commonZones[\"Arcane2\"]\n zoneData[\"White\"][\"Tarot\"] = commonZones[\"Tarot\"]\n zoneData[\"White\"][\"Accessory\"] = commonZones[\"Accessory\"]\n zoneData[\"White\"][\"Blank1\"] = commonZones[\"Blank1\"]\n zoneData[\"White\"][\"Blank2\"] = commonZones[\"Blank2\"]\n zoneData[\"White\"][\"Blank3\"] = commonZones[\"Blank3\"]\n zoneData[\"White\"][\"Blank4\"] = commonZones[\"Blank4\"]\n zoneData[\"White\"][\"Blank5\"] = commonZones[\"Blank5\"]\n zoneData[\"White\"][\"Blank6\"] = commonZones[\"Blank6\"]\n zoneData[\"White\"][\"Threat1\"] = commonZones[\"Threat1\"]\n zoneData[\"White\"][\"Threat2\"] = commonZones[\"Threat2\"]\n zoneData[\"White\"][\"Threat3\"] = commonZones[\"Threat3\"]\n zoneData[\"White\"][\"Threat4\"] = commonZones[\"Threat4\"]\n zoneData[\"White\"][\"Minicard\"] = { -1, 0, -1.45 }\n zoneData[\"White\"][\"SetAside1\"] = { 2.35, 0, -0.520 }\n zoneData[\"White\"][\"SetAside2\"] = { 2.35, 0, 0.042 }\n zoneData[\"White\"][\"SetAside3\"] = { 2.35, 0, 0.605 }\n zoneData[\"White\"][\"UnderSetAside3\"] = { 2.50, 0, 0.805 }\n zoneData[\"White\"][\"SetAside4\"] = { 2.78, 0, -0.520 }\n zoneData[\"White\"][\"SetAside5\"] = { 2.78, 0, 0.042 }\n zoneData[\"White\"][\"SetAside6\"] = { 2.78, 0, 0.605 }\n zoneData[\"White\"][\"UnderSetAside6\"] = { 2.93, 0, 0.805 }\n\n zoneData[\"Orange\"] = {}\n zoneData[\"Orange\"][\"Investigator\"] = commonZones[\"Investigator\"]\n zoneData[\"Orange\"][\"Deck\"] = commonZones[\"Deck\"]\n zoneData[\"Orange\"][\"Discard\"] = commonZones[\"Discard\"]\n zoneData[\"Orange\"][\"Ally\"] = commonZones[\"Ally\"]\n zoneData[\"Orange\"][\"Body\"] = commonZones[\"Body\"]\n zoneData[\"Orange\"][\"Hand1\"] = commonZones[\"Hand1\"]\n zoneData[\"Orange\"][\"Hand2\"] = commonZones[\"Hand2\"]\n zoneData[\"Orange\"][\"Arcane1\"] = commonZones[\"Arcane1\"]\n zoneData[\"Orange\"][\"Arcane2\"] = commonZones[\"Arcane2\"]\n zoneData[\"Orange\"][\"Tarot\"] = commonZones[\"Tarot\"]\n zoneData[\"Orange\"][\"Accessory\"] = commonZones[\"Accessory\"]\n zoneData[\"Orange\"][\"Blank1\"] = commonZones[\"Blank1\"]\n zoneData[\"Orange\"][\"Blank2\"] = commonZones[\"Blank2\"]\n zoneData[\"Orange\"][\"Blank3\"] = commonZones[\"Blank3\"]\n zoneData[\"Orange\"][\"Blank4\"] = commonZones[\"Blank4\"]\n zoneData[\"Orange\"][\"Blank5\"] = commonZones[\"Blank5\"]\n zoneData[\"Orange\"][\"Blank6\"] = commonZones[\"Blank6\"]\n zoneData[\"Orange\"][\"Threat1\"] = commonZones[\"Threat1\"]\n zoneData[\"Orange\"][\"Threat2\"] = commonZones[\"Threat2\"]\n zoneData[\"Orange\"][\"Threat3\"] = commonZones[\"Threat3\"]\n zoneData[\"Orange\"][\"Threat4\"] = commonZones[\"Threat4\"]\n zoneData[\"Orange\"][\"Minicard\"] = { 1, 0, -1.45 }\n zoneData[\"Orange\"][\"SetAside1\"] = { -2.35, 0, -0.520 }\n zoneData[\"Orange\"][\"SetAside2\"] = { -2.35, 0, 0.042}\n zoneData[\"Orange\"][\"SetAside3\"] = { -2.35, 0, 0.605 }\n zoneData[\"Orange\"][\"UnderSetAside3\"] = { -2.50, 0, 0.805 }\n zoneData[\"Orange\"][\"SetAside4\"] = { -2.78, 0, -0.520 }\n zoneData[\"Orange\"][\"SetAside5\"] = { -2.78, 0, 0.042 }\n zoneData[\"Orange\"][\"SetAside6\"] = { -2.78, 0, 0.605 }\n zoneData[\"Orange\"][\"UnderSetAside6\"] = { -2.93, 0, 0.805 }\n\n -- Green positions are the same as White and Red the same as Orange\n zoneData[\"Red\"] = zoneData[\"Orange\"]\n zoneData[\"Green\"] = zoneData[\"White\"]\n\n -- Gets the global position for the given zone on the specified player mat.\n ---@param playerColor string Color name of the player mat to get the zone position for (e.g. \"Red\")\n ---@param zoneName string Name of the zone to get the position for. See Zones object documentation for a list of valid zones.\n ---@return tts__Vector|nil: Global position table, or nil if an invalid player color or zone is specified\n Zones.getZonePosition = function(playerColor, zoneName)\n if (playerColor ~= \"Red\"\n and playerColor ~= \"Orange\"\n and playerColor ~= \"White\"\n and playerColor ~= \"Green\") then\n return nil\n end\n return playmatApi.transformLocalPosition(zoneData[playerColor][zoneName], playerColor)\n end\n\n -- Return the global rotation for a card on the given player mat, based on its zone.\n ---@param playerColor string Color name of the player mat to get the rotation for (e.g. \"Red\")\n ---@param zoneName string Name of the zone. See Zones object documentation for a list of valid zones.\n ---@return tts__Vector: Global rotation vector for the given card. This will include the\n -- Y rotation to orient the card on the given player mat as well as a\n -- Z rotation to place the card face up or face down.\n Zones.getDefaultCardRotation = function(playerColor, zoneName)\n local cardRotation = playmatApi.returnRotation(playerColor)\n if zoneName == \"Deck\" then\n cardRotation = cardRotation + Vector(0, 0, 180)\n end\n return cardRotation\n end\n\n return Zones\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"arkhamdb/DeckImporterMain\")\nend)\n__bundle_register(\"arkhamdb/ArkhamDb\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local allCardsBagApi = require(\"playercards/AllCardsBagApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n\n local ArkhamDb = {}\n local internal = {}\n \n local tabooList = {}\n local configuration\n\n local RANDOM_WEAKNESS_ID = \"01000\"\n\n ---@class Request\n local Request = {}\n\n -- Sets up the ArkhamDb interface. Should be called from the parent object on load.\n ArkhamDb.initialize = function()\n configuration = internal.getConfiguration()\n Request.start({ configuration.api_uri, configuration.taboo }, function(status)\n local json = JSON.decode(internal.fixUtf16String(status.text))\n for _, taboo in pairs(json) do\n local cards = {}\n\n for _, card in pairs(JSON.decode(taboo.cards)) do\n cards[card.code] = true\n end\n\n tabooList[taboo.id] = {\n date = taboo.date_start,\n cards = cards\n }\n end\n return true, nil\n end)\n end\n\n -- Start the deck build process for the given player color and deck ID. This\n -- will retrieve the deck from ArkhamDB, and pass to a callback for processing.\n ---@param playerColor string Color name of the player mat to place this deck on (e.g. \"Red\").\n ---@param deckId string ArkhamDB deck id to be loaded\n ---@param isPrivate boolean Whether this deck is published or private on ArkhamDB\n ---@param loadNewest boolean Whether the newest version of this deck should be loaded\n ---@param loadInvestigators boolean Whether investigator cards should be loaded as part of this deck\n ---@param callback function Callback which will be sent the results of this load\n --- Parameters to the callback will be:\n --- slots table A map of card ID to count in the deck\n --- investigatorCode String. ID of the investigator in this deck\n --- customizations table The decoded table of customization upgrades in this deck\n --- playerColor String. Color this deck is being loaded for\n ---@return boolean\n ---@return string\n ArkhamDb.getDecklist = function(\n playerColor,\n deckId,\n isPrivate,\n loadNewest,\n loadInvestigators,\n callback)\n -- Get a simple card to see if the bag indexes are complete. If not, abort\n -- the deck load. The called method will handle player notification.\n local checkCard = allCardsBagApi.getCardById(\"01001\")\n if (checkCard ~= nil and checkCard.data == nil) then\n return false, \"Indexing not complete\"\n end\n\n local deckUri = {\n configuration.api_uri,\n isPrivate and configuration.private_deck or configuration.public_deck,\n deckId\n }\n\n local deck = Request.start(deckUri, function(status)\n if string.find(status.text, \"\u003c!DOCTYPE html\u003e\") then\n internal.maybePrint(\"Private deck ID \" .. deckId .. \" is not shared\", playerColor)\n return false, \"Private deck \" .. deckId .. \" is not shared\"\n end\n local json = JSON.decode(status.text)\n\n if not json then\n internal.maybePrint(\"Deck ID \" .. deckId .. \" not found\", playerColor)\n return false, \"Deck not found!\"\n end\n\n return true, json\n end)\n\n deck:with(internal.onDeckResult, playerColor, loadNewest, loadInvestigators, callback)\n end\n\n -- Logs that a card could not be loaded in the mod by printing it to the console in the given\n -- color of the player owning the deck. Attempts to look up the name on ArkhamDB for clarity,\n -- but prints the card ID if the name cannot be retrieved.\n ---@param cardId string ArkhamDB ID of the card that could not be found\n ---@param playerColor string Color of the player's deck that had the problem\n ArkhamDb.logCardNotFound = function(cardId, playerColor)\n local request = Request.start({\n configuration.api_uri,\n configuration.cards,\n cardId\n },\n function(result)\n local adbCardInfo = JSON.decode(internal.fixUtf16String(result.text))\n local cardName = adbCardInfo.real_name\n if (cardName ~= nil) then\n if (adbCardInfo.xp ~= nil and adbCardInfo.xp \u003e 0) then\n cardName = cardName .. \" (\" .. adbCardInfo.xp .. \")\"\n end\n internal.maybePrint(\"Card not found: \" .. cardName .. \", card ID \" .. cardId, playerColor)\n else\n internal.maybePrint(\"Card not found in ArkhamDB/Index, ID \" .. cardId, playerColor)\n end\n end)\n end\n\n -- Callback when the deck information is received from ArkhamDB. Parses the\n -- response then applies standard transformations to the deck such as adding\n -- random weaknesses and checking for taboos. Once the deck is processed,\n -- passes to loadCards to actually spawn the defined deck.\n ---@param deck table ArkhamImportDeck\n ---@param playerColor string Color name of the player mat to place this deck on (e.g. \"Red\")\n ---@param loadNewest boolean Whether the newest version of this deck should be loaded\n ---@param loadInvestigators boolean Whether investigator cards should be loaded as part of this deck\n ---@param callback function Callback which will be sent the results of this load.\n --- Parameters to the callback will be:\n --- slots table A map of card ID to count in the deck\n --- investigatorCode String. ID of the investigator in this deck\n --- bondedList A table of cardID keys to meaningless values. Card IDs in this list were\n --- added from a parent bonded card.\n --- customizations table The decoded table of customization upgrades in this deck\n --- playerColor String. Color this deck is being loaded for\n internal.onDeckResult = function(deck, playerColor, loadNewest, loadInvestigators, callback)\n -- Load the next deck in the upgrade path if the option is enabled\n if (loadNewest and deck.next_deck ~= nil and deck.next_deck ~= \"\") then\n buildDeck(playerColor, deck.next_deck)\n return\n end\n\n internal.maybePrint(table.concat({ \"Found decklist: \", deck.name }), playerColor)\n\n -- Initialize deck slot table and perform common transformations. The order of these should not\n -- be changed, as later steps may act on cards added in each. For example, a random weakness or\n -- investigator may have bonded cards or taboo entries, and should be present\n local slots = deck.slots\n internal.maybeDrawRandomWeakness(slots, playerColor)\n\n -- handles alternative investigators (parallel, promo or revised art)\n local loadAltInvestigator = \"normal\"\n if loadInvestigators then\n loadAltInvestigator = internal.addInvestigatorCards(deck, slots)\n end\n\n internal.maybeModifyDeckFromDescription(slots, deck.description_md, playerColor)\n internal.maybeAddSummonedServitor(slots)\n internal.maybeAddOnTheMend(slots, playerColor)\n internal.maybeAddRealityAcidReference(slots)\n local bondList = internal.extractBondedCards(slots)\n internal.checkTaboos(deck.taboo_id, slots, playerColor)\n internal.maybeAddUpgradeSheets(slots)\n\n -- get upgrades for customizable cards\n local customizations = {}\n if deck.meta then\n customizations = JSON.decode(deck.meta)\n end\n\n callback(slots, deck.investigator_code, bondList, customizations, playerColor, loadAltInvestigator)\n end\n\n -- Checks to see if the slot list includes the random weakness ID. If it does,\n -- removes it from the deck and replaces it with the ID of a random basic weakness provided by the\n -- all cards bag\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n --- of those cards which will be spawned\n ---@param playerColor string Color of the player this deck is being loaded for. Used for broadcast\n --- if a weakness is added.\n internal.maybeDrawRandomWeakness = function(slots, playerColor)\n local randomWeaknessAmount = slots[RANDOM_WEAKNESS_ID] or 0\n slots[RANDOM_WEAKNESS_ID] = nil\n\n if randomWeaknessAmount ~= 0 then\n for i=1, randomWeaknessAmount do\n local weaknessId = allCardsBagApi.getRandomWeaknessId()\n slots[weaknessId] = (slots[weaknessId] or 0) + 1\n end\n internal.maybePrint(\"Added \" .. randomWeaknessAmount .. \" random basic weakness(es) to deck\", playerColor)\n end\n end\n\n -- Adds both the investigator (XXXXX) and minicard (XXXXX-m) slots with one copy each\n ---@param deck table The processed ArkhamDB deck response\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the\n --- number of those cards which will be spawned\n ---@return string: Contains the name of the art that should be loaded (\"normal\", \"promo\" or \"revised\")\n internal.addInvestigatorCards = function(deck, slots)\n local investigatorId = deck.investigator_code\n slots[investigatorId .. \"-m\"] = 1\n local deckMeta = JSON.decode(deck.meta)\n\n -- handling alternative investigator art and parallel investigators\n local loadAltInvestigator = \"normal\"\n if deckMeta ~= nil then\n local altFrontId = tonumber(deckMeta.alternate_front) or 0\n local altBackId = tonumber(deckMeta.alternate_back) or 0\n local altArt = { front = \"normal\", back = \"normal\" }\n\n -- translating front ID\n if altFrontId \u003e 90000 and altFrontId \u003c 90100 then\n altArt.front = \"parallel\"\n elseif altFrontId \u003e 01500 and altFrontId \u003c 01506 then\n altArt.front = \"revised\"\n elseif altFrontId \u003e 98000 then\n altArt.front = \"promo\"\n end\n\n -- translating back ID\n if altBackId \u003e 90000 and altBackId \u003c 90100 then\n altArt.back = \"parallel\"\n elseif altBackId \u003e 01500 and altBackId \u003c 01506 then\n altArt.back = \"revised\"\n elseif altBackId \u003e 98000 then\n altArt.back = \"promo\"\n end\n\n -- updating investigatorID based on alt investigator selection\n -- precedence: parallel \u003e promo \u003e revised\n if altArt.front == \"parallel\" then\n if altArt.back == \"parallel\" then\n investigatorId = investigatorId .. \"-p\"\n else\n investigatorId = investigatorId .. \"-pf\"\n end\n elseif altArt.back == \"parallel\" then\n investigatorId = investigatorId .. \"-pb\"\n elseif altArt.front == \"promo\" or altArt.back == \"promo\" then\n loadAltInvestigator = \"promo\"\n elseif altArt.front == \"revised\" or altArt.back == \"revised\" then\n loadAltInvestigator = \"revised\"\n end\n end\n slots[investigatorId] = 1\n deck.investigator_code = investigatorId\n return loadAltInvestigator\n end\n\n -- Process the card list looking for the customizable cards, and add their upgrade sheets if needed\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n internal.maybeAddUpgradeSheets = function(slots)\n for cardId, _ in pairs(slots) do\n -- upgrade sheets for customizable cards\n local upgradesheet = allCardsBagApi.getCardById(cardId .. \"-c\")\n if upgradesheet ~= nil then\n slots[cardId .. \"-c\"] = 1\n end\n end\n end\n\n -- Process the card list looking for the Summoned Servitor, and add its minicard to the list if\n -- needed\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n internal.maybeAddSummonedServitor = function(slots)\n if slots[\"09080\"] ~= nil then\n slots[\"09080-m\"] = 1\n end\n end\n\n -- On the Mend should have 1-per-investigator copies set aside, but ArkhamDB always sends 1. Update\n -- the count based on the investigator count\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n ---@param playerColor string Color of the player this deck is being loaded for. Used for broadcast if an error occurs\n internal.maybeAddOnTheMend = function(slots, playerColor)\n if slots[\"09006\"] ~= nil then\n local investigatorCount = playAreaApi.getInvestigatorCount()\n if investigatorCount ~= nil then\n slots[\"09006\"] = investigatorCount\n else\n internal.maybePrint(\"Something went wrong with the load, adding 4 copies of On the Mend\", playerColor)\n slots[\"09006\"] = 4\n end\n end\n end\n\n -- Process the card list looking for Reality Acid and adds the reference sheet when needed\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n internal.maybeAddRealityAcidReference = function(slots)\n if slots[\"89004\"] ~= nil then\n slots[\"89005\"] = 1\n end\n end\n\n -- Processes the deck description from ArkhamDB and modifies the slot list accordingly\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n ---@param description string The deck desription from ArkhamDB\n internal.maybeModifyDeckFromDescription = function(slots, description, playerColor)\n -- check for import instructions\n local pos = string.find(description, \"++SCED import instructions++\")\n if not pos then return end\n\n -- remove everything before instructions\n local tempStr = string.sub(description, pos)\n\n -- parse each line in instructions\n for line in tempStr:gmatch(\"([^\\n]+)\") do\n -- remove dashes at the start\n line = line:gsub(\"%- \", \"\")\n\n -- remove spaces\n line = line:gsub(\"%s\", \"\")\n\n -- remove balanced brackets\n line = line:gsub(\"%b()\", \"\")\n line = line:gsub(\"%b[]\", \"\")\n\n -- get instructor\n local instructor = \"\"\n for word in line:gmatch(\"%a+:\") do\n instructor = word\n break\n end\n\n -- go to the next line if no valid instructor found\n if instructor ~= \"add:\" and instructor ~= \"remove:\" then\n goto nextLine\n end\n\n -- remove instructor from line\n line = line:gsub(instructor, \"\")\n\n -- evaluate instructions\n for str in line:gmatch(\"([^,]+)\") do\n if instructor == \"add:\" then\n slots[str] = (slots[str] or 0) + 1\n elseif instructor == \"remove:\" then\n if slots[str] == nil then\n internal.maybePrint(\"Tried to remove card ID \" .. str .. \", but didn't find card in deck.\", playerColor)\n else\n slots[str] = math.max(slots[str] - 1, 0)\n\n -- fully remove cards that have a quantity of 0\n if slots[str] == 0 then\n slots[str] = nil\n\n -- also remove related minicard\n slots[str .. \"-m\"] = nil\n end\n end\n end\n end\n\n -- jump mark at the end of the loop\n ::nextLine::\n end\n end\n\n -- Process the slot list and looks for any cards which are bonded to those in the deck. Adds those cards to the slot list.\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned\n internal.extractBondedCards = function(slots)\n -- Create a list of bonded cards first so we don't modify slots while iterating\n local bondedCards = { }\n local bondedList = { }\n for cardId, cardCount in pairs(slots) do\n local card = allCardsBagApi.getCardById(cardId)\n if card ~= nil and card.metadata.bonded ~= nil then\n for _, bond in ipairs(card.metadata.bonded) do\n -- 'unlimited' upper limit for cards without this data\n local maxCount = bond.maxCount or 99\n\n -- add a bonded card for each copy of the parent card (until the max value is reached)\n bondedCards[bond.id] = math.min(bond.count * cardCount, maxCount)\n\n -- We need to know which cards are bonded to determine their position, remember them\n bondedList[bond.id] = true\n\n -- Also adding taboo versions of bonded cards to the list\n bondedList[bond.id .. \"-t\"] = true\n end\n end\n end\n\n -- Add any bonded cards to the main slots list\n for bondedId, bondedCount in pairs(bondedCards) do\n slots[bondedId] = bondedCount\n end\n\n return bondedList\n end\n\n -- Check the deck for cards on its taboo list. If they're found, replace the entry in the slot with the Taboo id (i.e. \"XXXX\" becomes \"XXXX-t\")\n ---@param tabooId string The deck's taboo ID, taken from the deck response taboo_id field. May be nil, indicating that no taboo list should be used\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned\n internal.checkTaboos = function(tabooId, slots, playerColor)\n if tabooId then\n for cardId, _ in pairs(tabooList[tabooId].cards) do\n if slots[cardId] ~= nil then\n -- Make sure there's a taboo version of the card before we replace it\n -- SCED only maintains the most recent taboo cards. If a deck is using\n -- an older taboo list it's possible the card isn't a taboo any more\n local tabooCard = allCardsBagApi.getCardById(cardId .. \"-t\")\n if tabooCard == nil then\n local basicCard = allCardsBagApi.getCardById(cardId)\n internal.maybePrint(\"Taboo version for \" .. basicCard.data.Nickname .. \" is not available. Using standard version\", playerColor)\n else\n slots[cardId .. \"-t\"] = slots[cardId]\n slots[cardId] = nil\n end\n end\n end\n end\n end\n\n internal.maybePrint = function(message, playerColor)\n if playerColor ~= \"None\" then\n printToAll(message, playerColor)\n end\n end\n\n -- Gets the ArkhamDB config info from the configuration object.\n ---@return table: configuration data\n internal.getConfiguration = function()\n local configuration = getObjectsWithTag(\"import_configuration_provider\")[1].getTable(\"configuration\")\n printPriority = configuration.priority\n return configuration\n end\n\n internal.fixUtf16String = function(str)\n return str:gsub(\"\\\\u(%w%w%w%w)\", function(match)\n return string.char(tonumber(match, 16))\n end)\n end\n\n Request = {\n is_done = false,\n is_successful = false\n }\n\n -- Creates a new instance of a Request. Should not be directly called. Instead use Request.start() and Request.deferred().\n ---@param uri table\n ---@param configure fun(request, status)\n ---@return Request\n function Request:new(uri, configure)\n local this = {}\n\n setmetatable(this, self)\n self.__index = self\n\n if type(uri) == \"table\" then\n uri = table.concat(uri, \"/\")\n end\n\n this.uri = uri\n WebRequest.get(uri, function(status) configure(this, status) end)\n\n return this\n end\n\n -- Creates a new request. on_success should set the request's is_done, is_successful, and content variables.\n -- Deferred should be used when you don't want to set is_done immediately (such as if you want to wait for another request to finish)\n ---@param uri table\n ---@param on_success fun(request, status, vararg)\n ---@param on_error fun(status)|nil\n ---@return Request\n function Request.deferred(uri, on_success, on_error, ...)\n local parameters = table.pack(...)\n return Request:new(uri, function(request, status)\n if (status.is_done) then\n if (status.is_error) then\n request.error_message = on_error and on_error(status, table.unpack(parameters)) or status.error\n request.is_successful = false\n request.is_done = true\n else\n on_success(request, status)\n end\n end\n end)\n end\n\n -- Creates a new request. on_success should return whether the resultant data is as expected, and the processed content of the request.\n ---@param uri table\n ---@param on_success fun(status, vararg): boolean, any\n ---@param on_error nil|fun(status, vararg): string\n ---@vararg any\n ---@return Request\n function Request.start(uri, on_success, on_error, ...)\n local parameters = table.pack(...)\n return Request.deferred(uri, function(request, status)\n local result, message = on_success(status, table.unpack(parameters))\n if not result then request.error_message = message else request.content = message end\n request.is_successful = result\n request.is_done = true\n end, on_error, table.unpack(parameters))\n end\n\n ---@param requests Request[]\n ---@param on_success fun(content: any, vararg: any)\n ---@param on_error fun(requests: Request, vararg: any)|nil\n ---@vararg any\n function Request.with_all(requests, on_success, on_error, ...)\n local parameters = table.pack(...)\n\n Wait.condition(function()\n local results = {}\n local errors = {}\n\n for _, request in ipairs(requests) do\n if request.is_successful then\n table.insert(results, request.content)\n else\n table.insert(errors, request)\n end\n end\n\n if (#errors \u003c= 0) then\n on_success(results, table.unpack(parameters))\n elseif on_error == nil then\n for _, request in ipairs(errors) do\n internal.maybePrint(table.concat({ \"[ERROR]\", request.uri, \":\", request.error_message }))\n end\n else\n on_error(requests, table.unpack(parameters))\n end\n end, function()\n for _, request in ipairs(requests) do\n if not request.is_done then return false end\n end\n return true\n end)\n end\n\n function Request:with(callback, ...)\n local arguments = table.pack(...)\n Wait.condition(function()\n if self.is_successful then\n callback(self.content, table.unpack(arguments))\n end\n end, function() return self.is_done\n end)\n end\n\n return ArkhamDb\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"playermat/Zones\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Sets up and returns coordinates for all possible spawn zones. Because Lua assigns tables by reference\n-- and there is no built-in function to copy a table this is relatively brute force.\n--\n-- Positions are all relative to the player mat, and most are consistent. The\n-- exception are the SetAside# zones, which are placed to the left of the mat\n-- for White/Green, and the right of the mat for Orange/Red.\n--\n-- Investigator: Investigator card area.\n-- Minicard: Placement for the investigator's minicard, just above the player mat\n-- Deck, Discard: Standard locations for the deck and discard piles.\n-- Blank1: used for assets that start in play (e.g. Duke)\n-- Tarot, Hand1, Hand2, Ally, Blank4, Accessory, Arcane1, Arcane2, Body: Asset slot positions\n-- Threat[1-4]: Threat area slots. Threat[1-3] correspond to the named threat area slots, and Threat4 is the blank threat area slot.\n-- SetAside[1-3]: Column closest to the player mat, with 1 at the top and 3 at the bottom.\n-- SetAside[4-6]: Column farther away from the mat, with 4 at the top and 6 at the bottom.\n-- SetAside1: Permanent cards\n-- SetAside2: Bonded cards\n-- SetAside3: Ancestral Knowledge / Underworld Market\n-- SetAside4: Upgrade sheets for customizable cards\n-- SetAside5: Hunch Deck for Joe Diamond\n-- SetAside6: currently unused\ndo\n local playmatApi = require(\"playermat/PlaymatApi\")\n local Zones = { }\n\n local commonZones = {}\n commonZones[\"Investigator\"] = { -1.177, 0, 0.002 }\n commonZones[\"Deck\"] = { -1.82, 0, 0 }\n commonZones[\"Discard\"] = { -1.82, 0, 0.61 }\n commonZones[\"Ally\"] = { -0.615, 0, 0.024 }\n commonZones[\"Body\"] = { -0.630, 0, 0.553 }\n commonZones[\"Hand1\"] = { 0.215, 0, 0.042 }\n commonZones[\"Hand2\"] = { -0.180, 0, 0.037 }\n commonZones[\"Arcane1\"] = { 0.212, 0, 0.559 }\n commonZones[\"Arcane2\"] = { -0.171, 0, 0.557 }\n commonZones[\"Tarot\"] = { 0.602, 0, 0.033 }\n commonZones[\"Accessory\"] = { 0.602, 0, 0.555 }\n commonZones[\"Blank1\"] = { 1.758, 0, 0.040 }\n commonZones[\"Blank2\"] = { 1.754, 0, 0.563 }\n commonZones[\"Blank3\"] = { 1.371, 0, 0.038 }\n commonZones[\"Blank4\"] = { 1.371, 0, 0.558 }\n commonZones[\"Blank5\"] = { 0.98, 0, 0.035 }\n commonZones[\"Blank6\"] = { 0.977, 0, 0.556 }\n commonZones[\"Threat1\"] = { -0.911, 0, -0.625 }\n commonZones[\"Threat2\"] = { -0.454, 0, -0.625 }\n commonZones[\"Threat3\"] = { 0.002, 0, -0.625 }\n commonZones[\"Threat4\"] = { 0.459, 0, -0.625 }\n\n local zoneData = {}\n zoneData[\"White\"] = {}\n zoneData[\"White\"][\"Investigator\"] = commonZones[\"Investigator\"]\n zoneData[\"White\"][\"Deck\"] = commonZones[\"Deck\"]\n zoneData[\"White\"][\"Discard\"] = commonZones[\"Discard\"]\n zoneData[\"White\"][\"Ally\"] = commonZones[\"Ally\"]\n zoneData[\"White\"][\"Body\"] = commonZones[\"Body\"]\n zoneData[\"White\"][\"Hand1\"] = commonZones[\"Hand1\"]\n zoneData[\"White\"][\"Hand2\"] = commonZones[\"Hand2\"]\n zoneData[\"White\"][\"Arcane1\"] = commonZones[\"Arcane1\"]\n zoneData[\"White\"][\"Arcane2\"] = commonZones[\"Arcane2\"]\n zoneData[\"White\"][\"Tarot\"] = commonZones[\"Tarot\"]\n zoneData[\"White\"][\"Accessory\"] = commonZones[\"Accessory\"]\n zoneData[\"White\"][\"Blank1\"] = commonZones[\"Blank1\"]\n zoneData[\"White\"][\"Blank2\"] = commonZones[\"Blank2\"]\n zoneData[\"White\"][\"Blank3\"] = commonZones[\"Blank3\"]\n zoneData[\"White\"][\"Blank4\"] = commonZones[\"Blank4\"]\n zoneData[\"White\"][\"Blank5\"] = commonZones[\"Blank5\"]\n zoneData[\"White\"][\"Blank6\"] = commonZones[\"Blank6\"]\n zoneData[\"White\"][\"Threat1\"] = commonZones[\"Threat1\"]\n zoneData[\"White\"][\"Threat2\"] = commonZones[\"Threat2\"]\n zoneData[\"White\"][\"Threat3\"] = commonZones[\"Threat3\"]\n zoneData[\"White\"][\"Threat4\"] = commonZones[\"Threat4\"]\n zoneData[\"White\"][\"Minicard\"] = { -1, 0, -1.45 }\n zoneData[\"White\"][\"SetAside1\"] = { 2.35, 0, -0.520 }\n zoneData[\"White\"][\"SetAside2\"] = { 2.35, 0, 0.042 }\n zoneData[\"White\"][\"SetAside3\"] = { 2.35, 0, 0.605 }\n zoneData[\"White\"][\"UnderSetAside3\"] = { 2.50, 0, 0.805 }\n zoneData[\"White\"][\"SetAside4\"] = { 2.78, 0, -0.520 }\n zoneData[\"White\"][\"SetAside5\"] = { 2.78, 0, 0.042 }\n zoneData[\"White\"][\"SetAside6\"] = { 2.78, 0, 0.605 }\n zoneData[\"White\"][\"UnderSetAside6\"] = { 2.93, 0, 0.805 }\n\n zoneData[\"Orange\"] = {}\n zoneData[\"Orange\"][\"Investigator\"] = commonZones[\"Investigator\"]\n zoneData[\"Orange\"][\"Deck\"] = commonZones[\"Deck\"]\n zoneData[\"Orange\"][\"Discard\"] = commonZones[\"Discard\"]\n zoneData[\"Orange\"][\"Ally\"] = commonZones[\"Ally\"]\n zoneData[\"Orange\"][\"Body\"] = commonZones[\"Body\"]\n zoneData[\"Orange\"][\"Hand1\"] = commonZones[\"Hand1\"]\n zoneData[\"Orange\"][\"Hand2\"] = commonZones[\"Hand2\"]\n zoneData[\"Orange\"][\"Arcane1\"] = commonZones[\"Arcane1\"]\n zoneData[\"Orange\"][\"Arcane2\"] = commonZones[\"Arcane2\"]\n zoneData[\"Orange\"][\"Tarot\"] = commonZones[\"Tarot\"]\n zoneData[\"Orange\"][\"Accessory\"] = commonZones[\"Accessory\"]\n zoneData[\"Orange\"][\"Blank1\"] = commonZones[\"Blank1\"]\n zoneData[\"Orange\"][\"Blank2\"] = commonZones[\"Blank2\"]\n zoneData[\"Orange\"][\"Blank3\"] = commonZones[\"Blank3\"]\n zoneData[\"Orange\"][\"Blank4\"] = commonZones[\"Blank4\"]\n zoneData[\"Orange\"][\"Blank5\"] = commonZones[\"Blank5\"]\n zoneData[\"Orange\"][\"Blank6\"] = commonZones[\"Blank6\"]\n zoneData[\"Orange\"][\"Threat1\"] = commonZones[\"Threat1\"]\n zoneData[\"Orange\"][\"Threat2\"] = commonZones[\"Threat2\"]\n zoneData[\"Orange\"][\"Threat3\"] = commonZones[\"Threat3\"]\n zoneData[\"Orange\"][\"Threat4\"] = commonZones[\"Threat4\"]\n zoneData[\"Orange\"][\"Minicard\"] = { 1, 0, -1.45 }\n zoneData[\"Orange\"][\"SetAside1\"] = { -2.35, 0, -0.520 }\n zoneData[\"Orange\"][\"SetAside2\"] = { -2.35, 0, 0.042}\n zoneData[\"Orange\"][\"SetAside3\"] = { -2.35, 0, 0.605 }\n zoneData[\"Orange\"][\"UnderSetAside3\"] = { -2.50, 0, 0.805 }\n zoneData[\"Orange\"][\"SetAside4\"] = { -2.78, 0, -0.520 }\n zoneData[\"Orange\"][\"SetAside5\"] = { -2.78, 0, 0.042 }\n zoneData[\"Orange\"][\"SetAside6\"] = { -2.78, 0, 0.605 }\n zoneData[\"Orange\"][\"UnderSetAside6\"] = { -2.93, 0, 0.805 }\n\n -- Green positions are the same as White and Red the same as Orange\n zoneData[\"Red\"] = zoneData[\"Orange\"]\n zoneData[\"Green\"] = zoneData[\"White\"]\n\n -- Gets the global position for the given zone on the specified player mat.\n ---@param playerColor string Color name of the player mat to get the zone position for (e.g. \"Red\")\n ---@param zoneName string Name of the zone to get the position for. See Zones object documentation for a list of valid zones.\n ---@return tts__Vector|nil: Global position table, or nil if an invalid player color or zone is specified\n Zones.getZonePosition = function(playerColor, zoneName)\n if (playerColor ~= \"Red\"\n and playerColor ~= \"Orange\"\n and playerColor ~= \"White\"\n and playerColor ~= \"Green\") then\n return nil\n end\n return playmatApi.transformLocalPosition(zoneData[playerColor][zoneName], playerColor)\n end\n\n -- Return the global rotation for a card on the given player mat, based on its zone.\n ---@param playerColor string Color name of the player mat to get the rotation for (e.g. \"Red\")\n ---@param zoneName string Name of the zone. See Zones object documentation for a list of valid zones.\n ---@return tts__Vector: Global rotation vector for the given card. This will include the\n -- Y rotation to orient the card on the given player mat as well as a\n -- Z rotation to place the card face up or face down.\n Zones.getDefaultCardRotation = function(playerColor, zoneName)\n local cardRotation = playmatApi.returnRotation(playerColor)\n if zoneName == \"Deck\" then\n cardRotation = cardRotation + Vector(0, 0, 180)\n end\n return cardRotation\n end\n\n return Zones\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"arkhamdb/DeckImporterMain\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"arkhamdb/DeckImporterUi\")\nrequire(\"playercards/PlayerCardSpawner\")\n\nlocal allCardsBagApi = require(\"playercards/AllCardsBagApi\")\nlocal arkhamDb = require(\"arkhamdb/ArkhamDb\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal zones = require(\"playermat/Zones\")\n\nlocal startsInPlayCount = 0\n\nfunction onLoad(script_state)\n initializeUi(JSON.decode(script_state))\n math.randomseed(os.time())\n arkhamDb.initialize()\nend\n\nfunction onSave() return JSON.encode(getUiState()) end\n\n-- Returns the zone name where the specified card should be placed, based on its metadata.\n---@param cardMetadata table Contains card metadata\n---@return string Zone Name of the zone such as \"Deck\", \"SetAside1\", etc.\n-- See Zones object documentation for a list of valid zones.\nfunction getDefaultCardZone(cardMetadata, bondedList)\n if (cardMetadata.id == \"09080-m\") then -- Have to check the Servitor before other minicards\n return \"SetAside6\"\n elseif (cardMetadata.id == \"09006\") then -- On The Mend is set aside\n return \"SetAside2\"\n elseif bondedList[cardMetadata.id] then\n return \"SetAside2\"\n elseif cardMetadata.type == \"Investigator\" then\n return \"Investigator\"\n elseif cardMetadata.type == \"Minicard\" then\n return \"Minicard\"\n elseif cardMetadata.type == \"UpgradeSheet\" then\n return \"SetAside4\"\n elseif cardMetadata.startsInPlay then\n return startsInPlayTracker()\n elseif cardMetadata.permanent then\n return \"SetAside1\"\n -- SetAside3 is used for Ancestral Knowledge / Underworld Market\n else\n return \"Deck\"\n end\nend\n\nfunction startsInPlayTracker()\n startsInPlayCount = startsInPlayCount + 1\n if startsInPlayCount \u003e 6 then\n broadcastToAll(\"Card that should start in play was placed with permanents because no blank slots remained\")\n return \"SetAside1\"\n else\n return \"Blank\" .. startsInPlayCount\n end\nend\n\nfunction buildDeck(playerColor, deckId)\n local uiState = getUiState()\n arkhamDb.getDecklist(\n playerColor,\n deckId,\n uiState.privateDeck,\n uiState.loadNewest,\n uiState.investigators,\n loadCards)\nend\n\n-- Process the slot list, which defines the card Ids and counts of cards to load. Spawn those cards\n-- at the appropriate zones and report an error to the user if any could not be loaded.\n-- This is a callback function which handles the results of ArkhamDb.getDecklist()\n-- This method uses an encapsulated coroutine with yields to make the card spawning cleaner.\n--\n---@param slots table Key-Value table of cardId:count. cardId is the ArkhamDB ID of the card to spawn,\n-- and count is the number which should be spawned\n---@param investigatorId string ArkhamDB ID (code) for this deck's investigator.\n-- Investigator cards should already be added to the slots list if they\n-- should be spawned, but this value is separate to check for special\n-- handling for certain investigators\n---@param bondedList table A table of cardID keys to meaningless values. Card IDs in this list were added\n-- from a parent bonded card.\n---@param customizations table ArkhamDB data for customizations on customizable cards\n---@param playerColor string Color name of the player mat to place this deck on (e.g. \"Red\")\n---@param loadAltInvestigator string Contains the name of alternative art for the investigator (\"normal\", \"revised\" or \"promo\")\nfunction loadCards(slots, investigatorId, bondedList, customizations, playerColor, loadAltInvestigator)\n function coinside()\n local cardsToSpawn = {}\n\n -- reset the startsInPlayCount\n startsInPlayCount = 0\n for cardId, cardCount in pairs(slots) do\n local card = allCardsBagApi.getCardById(cardId)\n if card ~= nil then\n local cardZone = getDefaultCardZone(card.metadata, bondedList)\n for i = 1, cardCount do\n table.insert(cardsToSpawn, { data = card.data, metadata = card.metadata, zone = cardZone })\n end\n\n slots[cardId] = 0\n end\n end\n\n handleAncestralKnowledge(cardsToSpawn)\n handleUnderworldMarket(cardsToSpawn, playerColor)\n handleHunchDeck(investigatorId, cardsToSpawn, bondedList, playerColor)\n handleSpiritDeck(investigatorId, cardsToSpawn, playerColor, customizations)\n handleCustomizableUpgrades(cardsToSpawn, customizations)\n handlePeteSignatureAssets(investigatorId, cardsToSpawn)\n\n -- Split the card list into separate lists for each zone\n local zoneDecks = buildZoneLists(cardsToSpawn)\n -- Spawn the list for each zone\n for zone, zoneCards in pairs(zoneDecks) do\n local deckPos = zones.getZonePosition(playerColor, zone):setAt(\"y\", 3)\n local deckRot = zones.getDefaultCardRotation(playerColor, zone)\n\n local callback = nil\n -- If cards are spread too close together TTS groups them weirdly, selecting multiples\n -- when hovering over a single card. This distance is the minimum to avoid that\n local spreadDistance = 1.15\n if (zone == \"SetAside4\") then\n -- SetAside4 is reserved for customization cards, and we want them spread on the table\n -- so their checkboxes are visible\n -- TO-DO: take into account that spreading will make multiple rows\n -- (this is affected by the user's local settings!)\n if (playerColor == \"White\") then\n deckPos.z = deckPos.z + (#zoneCards - 1) * spreadDistance\n elseif (playerColor == \"Green\") then\n deckPos.x = deckPos.x + (#zoneCards - 1) * spreadDistance\n end\n callback = function(deck) deck.spread(spreadDistance) end\n elseif zone == \"Deck\" then\n callback = function(deck) deckSpawned(deck, playerColor) end\n elseif zone == \"Investigator\" or zone == \"Minicard\" then\n callback = function(card) loadAltArt(card, loadAltInvestigator) end\n end\n Spawner.spawnCards(zoneCards, deckPos, deckRot, true, callback)\n coroutine.yield(0)\n end\n\n -- Look for any cards which haven't been loaded\n local hadError = false\n for cardId, remainingCount in pairs(slots) do\n if remainingCount \u003e 0 then\n hadError = true\n arkhamDb.logCardNotFound(cardId, playerColor)\n end\n end\n if (not hadError) then\n printToAll(\"Deck loaded successfully!\", playerColor)\n end\n return 1\n end\n\n startLuaCoroutine(self, \"coinside\")\nend\n\n-- Callback handler for the main deck spawning. Looks for cards which should start in hand, and\n-- draws them for the appropriate player.\n---@param deck tts__Object Callback-provided spawned deck object\n---@param playerColor string Color of the player to draw the cards to\nfunction deckSpawned(deck, playerColor)\n local player = Player[playmatApi.getPlayerColor(playerColor)]\n local handPos = player.getHandTransform(1).position -- Only one hand zone per player\n local deckCards = deck.getData().ContainedObjects\n\n -- Process in reverse order so taking cards out doesn't upset the indexing\n for i = #deckCards, 1, -1 do\n local cardMetadata = JSON.decode(deckCards[i].GMNotes) or { }\n if cardMetadata.startsInHand then\n deck.takeObject({ index = i - 1, position = handPos, flip = true, smooth = true})\n end\n end\n\n -- add the \"PlayerCard\" tag to the deck\n if deck and deck.type == \"Deck\" and deck.getQuantity() \u003e 1 then\n deck.addTag(\"PlayerCard\")\n end\nend\n\n-- Converts the Raven Quill's selections from card IDs to card names. This could be more elegant\n-- but the inputs are very static so we're using some brute force.\n---@param selectionString string provided by ArkhamDB, indicates the customization selections\n-- Should be either a single card ID or two separated by a ^ (e.g. XXXXX^YYYYY)\nfunction convertRavenQuillSelections(selectionString)\n if (string.len(selectionString) == 5) then\n return getCardName(selectionString)\n elseif (string.len(selectionString) == 11) then\n return getCardName(string.sub(selectionString, 1, 5)) .. \", \" .. getCardName(string.sub(selectionString, 7))\n end\nend\n\n-- Converts Grizzled's selections from a single string with \"^\".\n---@param selectionString string provided by ArkhamDB, indicates the customization selections\n-- Should be two Traits separated by a ^ (e.g. XXXXX^YYYYY)\nfunction convertGrizzledSelections(selectionString)\n return selectionString:gsub(\"%^\", \", \")\nend\n\n-- Returns the simple name of a card given its ID. This will find the card and strip any trailing\n-- SCED-specific suffixes such as (Taboo) or (Level)\nfunction getCardName(cardId)\n local card = allCardsBagApi.getCardById(cardId)\n if (card ~= nil) then\n local name = card.data.Nickname\n if (string.find(name, \" %(\")) then\n return string.sub(name, 1, string.find(name, \" %(\") - 1)\n else\n return name\n end\n end\nend\n\n-- Split a single list of cards into a separate table of lists, keyed by the zone\n---@param cards table Table of {cardData, cardMetadata, zone}\n---@return table ZoneNames Table with zoneName as index: {zoneName=card list}\nfunction buildZoneLists(cards)\n local zoneList = {}\n for _, card in ipairs(cards) do\n if zoneList[card.zone] == nil then\n zoneList[card.zone] = {}\n end\n table.insert(zoneList[card.zone], card)\n end\n\n return zoneList\nend\n\n-- Check to see if the deck list has Ancestral Knowledge. If it does, move 5 random skills to SetAside3\n---@param cardList table Deck list being created\nfunction handleAncestralKnowledge(cardList)\n local hasAncestralKnowledge = false\n local skillList = {}\n -- Have to process the entire list to check for Ancestral Knowledge and get all possible skills, so do both in one pass\n for i, card in ipairs(cardList) do\n if card.metadata.id == \"07303\" then\n hasAncestralKnowledge = true\n card.zone = \"SetAside3\"\n elseif (card.metadata.type == \"Skill\"\n and card.zone == \"Deck\"\n and not card.metadata.weakness) then\n table.insert(skillList, i)\n end\n end\n\n if not hasAncestralKnowledge then return end\n\n for i = 1, 5 do\n -- Move 5 random skills to SetAside3\n local skillListIndex = math.random(#skillList)\n cardList[skillList[skillListIndex]].zone = \"UnderSetAside3\"\n table.remove(skillList, skillListIndex)\n end\nend\n\n-- Check for and handle Underworld Market by moving all Illicit cards to UnderSetAside3\n---@param cardList table Deck list being created\n---@param playerColor string Color this deck is being loaded for\nfunction handleUnderworldMarket(cardList, playerColor)\n local hasMarket = false\n local illicitList = {}\n -- Process the entire list to check for Underworld Market and get all possible Illicit cards, doing both in one pass\n for i, card in ipairs(cardList) do\n if card.metadata.id == \"09077\" then\n -- Underworld Market found\n hasMarket = true\n card.zone = \"SetAside3\"\n elseif card.metadata.traits ~= nil and string.find(card.metadata.traits, \"Illicit\", 1, true) and card.zone == \"Deck\" then\n table.insert(illicitList, i)\n end\n end\n\n if not hasMarket then return end\n\n if #illicitList \u003c 10 then\n printToAll(\"Only \" .. #illicitList .. \" Illicit cards in your deck, you can't trigger Underworld Market's ability.\", playerColor)\n else\n -- Process cards to move them to the market deck. This is done in reverse\n -- order because the sorting needs to be reversed (deck sorts for face down)\n -- Performance here may be an issue, as table.remove() is an O(n) operation\n -- which makes the full shift O(n^2). But keep it simple unless it becomes\n -- a problem\n for i = #illicitList, 1, -1 do\n local moving = cardList[illicitList[i]]\n moving.zone = \"UnderSetAside3\"\n table.remove(cardList, illicitList[i])\n table.insert(cardList, moving)\n end\n\n if #illicitList \u003e 10 then\n printToAll(\"Moved all \" .. #illicitList .. \" Illicit cards to the Market deck, reduce it to 10\", playerColor)\n else\n printToAll(\"Built the Market deck\", playerColor)\n end\n end\nend\n\n-- If the investigator is Joe Diamond, extract all Insight events to SetAside5 to build the Hunch Deck\n---@param investigatorId string ID for the deck's investigator card. Passed separately because the\n--- investigator may not be included in the cardList\n---@param cardList table Deck list being created\n---@param playerColor string Color this deck is being loaded for\nfunction handleHunchDeck(investigatorId, cardList, bondedList, playerColor)\n if investigatorId ~= \"05002\" then return end\n\n local insightList = {}\n for i, card in ipairs(cardList) do\n if (card.metadata.type == \"Event\"\n and card.metadata.traits ~= nil\n and string.match(card.metadata.traits, \"Insight\")\n and bondedList[card.metadata.id] == nil) then\n table.insert(insightList, i)\n end\n end\n -- Process insights to move them to the hunch deck. This is done in reverse\n -- order because the sorting needs to be reversed (deck sorts for face down)\n -- Performance here may be an issue, as table.remove() is an O(n) operation\n -- which makes the full shift O(n^2). But keep it simple unless it becomes\n -- a problem\n for i = #insightList, 1, -1 do\n local moving = cardList[insightList[i]]\n moving.zone = \"SetAside5\"\n table.remove(cardList, insightList[i])\n table.insert(cardList, moving)\n end\n\n if #insightList \u003c 11 then\n printToAll(\"Joe's hunch deck must have 11 cards but the deck only has \" .. #insightList .. \" Insight events.\", playerColor)\n elseif #insightList \u003e 11 then\n printToAll(\"Moved all \" .. #insightList .. \" Insight events to the hunch deck, reduce it to 11.\", playerColor)\n else\n printToAll(\"Built Joe's hunch deck\", playerColor)\n end\nend\n\n-- If the investigator is Parallel Jim Culver, extract all Ally assets to SetAside5 to build the Spirit Deck\n---@param investigatorId string ID for the deck's investigator card. Passed separately because the\n--- investigator may not be included in the cardList\n---@param cardList table Deck list being created\n---@param playerColor string Color this deck is being loaded for\n---@param customizations table Additional deck information\nfunction handleSpiritDeck(investigatorId, cardList, playerColor, customizations)\n if investigatorId ~= \"02004-p\" and investigatorId ~= \"02004-pb\" then return end\n\n local spiritList = {}\n if customizations[\"extra_deck\"] then\n -- split by \",\"\n for str in string.gmatch(customizations[\"extra_deck\"], \"([^,]+)\") do\n local card = allCardsBagApi.getCardById(str)\n if card ~= nil then\n table.insert(cardList, { data = card.data, metadata = card.metadata, zone = \"SetAside5\" })\n table.insert(spiritList, str)\n end\n end\n else\n for i, card in ipairs(cardList) do\n if card.metadata.id == \"90053\" or (\n card.metadata.type == \"Asset\"\n and card.metadata.traits ~= nil\n and string.match(card.metadata.traits, \"Ally\")\n and card.metadata.level ~= nil\n and card.metadata.level \u003c 3) then\n table.insert(spiritList, i)\n end\n end\n\n -- Process allies to move them to the spirit deck. This is done in reverse\n -- order because the sorting needs to be reversed (deck sorts for face down)\n -- Performance here may be an issue, as table.remove() is an O(n) operation\n -- which makes the full shift O(n^2). But keep it simple unless it becomes\n -- a problem\n for i = #spiritList, 1, -1 do\n local moving = cardList[spiritList[i]]\n moving.zone = \"SetAside5\"\n table.remove(cardList, spiritList[i])\n table.insert(cardList, moving)\n end\n end\n\n if #spiritList \u003c 10 then\n printToAll(\"Jim's spirit deck must have 9 Ally assets but the deck only has \" .. (#spiritList - 1) .. \" Ally assets.\", playerColor)\n elseif #spiritList \u003e 11 then\n printToAll(\"Moved all \" .. (#spiritList - 1) .. \" Ally assets to the spirit deck, reduce it to 10 (including Vengeful Shade).\", playerColor)\n else\n printToAll(\"Built Jim's spirit deck\", playerColor)\n end\nend\n\n-- For any customization upgrade cards in the card list, process the metadata from the deck to\n-- set the save state to show the correct checkboxes/text field values\n---@param cardList table Deck list being created\n---@param customizations table ArkhamDB data for customizations on customizable cards\nfunction handleCustomizableUpgrades(cardList, customizations)\n for _, card in ipairs(cardList) do\n if card.metadata.type == \"UpgradeSheet\" then\n local baseId = string.sub(card.metadata.id, 1, 5)\n local upgrades = customizations[\"cus_\" .. baseId]\n\n if upgrades ~= nil then\n -- initialize tables\n -- markedBoxes: contains the amount of markedBoxes (left to right) per row (starting at row 1)\n -- inputValues: contains the amount of inputValues per row (starting at row 0)\n local selectedUpgrades = { }\n local index_xp = {}\n\n -- get the index and xp values (looks like this: X|X,X|X, ..)\n -- input string from ArkhamDB is split by \",\"\n for str in string.gmatch(customizations[\"cus_\" .. baseId], \"([^,]+)\") do\n table.insert(index_xp, str)\n end\n\n -- split each pair and assign it to the proper position in markedBoxes\n for _, entry in ipairs(index_xp) do\n -- counter increments from 1 to 3 and indicates the part of the string we are on\n -- usually: 1 = row, 2 = amount of check boxes, 3 = entry in inputfield\n local counter = 0\n local row = 0\n\n -- parsing the string for each row\n for str in entry:gmatch(\"([^|]+)\") do\n counter = counter + 1\n\n if counter == 1 then\n row = tonumber(str) + 1\n elseif counter == 2 then\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n end\n selectedUpgrades[row].xp = tonumber(str)\n elseif counter == 3 and str ~= \"\" then\n if baseId == \"09042\" then\n selectedUpgrades[row].text = convertRavenQuillSelections(str)\n elseif baseId == \"09101\" then\n selectedUpgrades[row].text = convertGrizzledSelections(str)\n elseif baseId == \"09079\" then -- Living Ink skill selection\n -- All skills, regardless of row, are placed in upgrade slot 1 as a comma-delimited list\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n if selectedUpgrades[1].text == nil then\n selectedUpgrades[1].text = str\n else\n selectedUpgrades[1].text = selectedUpgrades[1].text .. \",\" .. str\n end\n else\n selectedUpgrades[row].text = str\n end\n end\n end\n end\n\n -- write the loaded values to the save_data of the sheets\n card.data[\"LuaScriptState\"] = JSON.encode({ selections = selectedUpgrades })\n end\n end\n end\nend\n\n-- Handles cards that start in play under specific conditions for Ashcan Pete (Regular Pete - Duke, Parallel Pete - Guitar)\n---@param investigatorId string ID for the deck's investigator card. Passed separately because the\n--- investigator may not be included in the cardList\n---@param cardList table Deck list being created\nfunction handlePeteSignatureAssets(investigatorId, cardList)\n if investigatorId == \"02005\" or investigatorId == \"02005-pb\" then -- regular Pete's front\n for i, card in ipairs(cardList) do\n if card.metadata.id == \"02014\" then -- Duke\n card.zone = startsInPlayTracker()\n end\n end\n elseif investigatorId == \"02005-p\" or investigatorId == \"02005-pf\" then -- parallel Pete's front\n for i, card in ipairs(cardList) do\n if card.metadata.id == \"90047\" then -- Pete's Guitar\n card.zone = startsInPlayTracker()\n end\n end\n end\nend\n\n-- Callback function for investigator cards and minicards to set the correct state for alt art\n---@param card tts__Object Card which needs to be set the state for\n---@param loadAltInvestigator string Contains the name of alternative art for the investigator (\"normal\", \"revised\" or \"promo\")\nfunction loadAltArt(card, loadAltInvestigator)\n -- states are set up this way:\n -- 1 - normal, 2 - revised/promo, 3 - promo (if 2 is revised)\n -- This means we can always load the 2nd state for revised and just get the last state for promo\n if loadAltInvestigator == \"normal\" then\n return\n elseif loadAltInvestigator == \"revised\" then\n card.setState(2)\n elseif loadAltInvestigator == \"promo\" then\n local states = card.getStates()\n card.setState(#states)\n end\nend\nend)\n__bundle_register(\"arkhamdb/DeckImporterUi\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal allCardsBagApi = require(\"playercards/AllCardsBagApi\")\n\nlocal INPUT_FIELD_HEIGHT = 340\nlocal INPUT_FIELD_WIDTH = 1500\nlocal FIELD_COLOR = { 0.9, 0.7, 0.5 }\n\nlocal PRIVATE_TOGGLE_LABELS = {}\nPRIVATE_TOGGLE_LABELS[true] = \"Private\"\nPRIVATE_TOGGLE_LABELS[false] = \"Published\"\n\nlocal UPGRADED_TOGGLE_LABELS = {}\nUPGRADED_TOGGLE_LABELS[true] = \"Upgraded\"\nUPGRADED_TOGGLE_LABELS[false] = \"Specific\"\n\nlocal LOAD_INVESTIGATOR_TOGGLE_LABELS = {}\nLOAD_INVESTIGATOR_TOGGLE_LABELS[true] = \"Yes\"\nLOAD_INVESTIGATOR_TOGGLE_LABELS[false] = \"No\"\n\nlocal redDeckId = \"\"\nlocal orangeDeckId = \"\"\nlocal whiteDeckId = \"\"\nlocal greenDeckId = \"\"\n\nlocal privateDeck = true\nlocal loadNewestDeck = true\nlocal loadInvestigators = false\n\n-- Returns a table with the full state of the UI, including options and deck IDs.\n-- This can be used to persist via onSave(), or provide values for a load operation\n---@return uiStateTable uiStateTable Contains data about the current UI state\nfunction getUiState()\n return {\n redDeck = redDeckId,\n orangeDeck = orangeDeckId,\n whiteDeck = whiteDeckId,\n greenDeck = greenDeckId,\n privateDeck = privateDeck,\n loadNewest = loadNewestDeck,\n investigators = loadInvestigators\n }\nend\n\n-- Updates the state of the UI based on the provided table. Any values not provided will be left the same.\n---@param uiStateTable table Table of values to update on importer\nfunction setUiState(uiStateTable)\n self.clearButtons()\n self.clearInputs()\n initializeUi(uiStateTable)\nend\n\n-- Sets up the UI for the deck loader, populating fields from the given save state table decoded from onLoad()\nfunction initializeUi(savedUiState)\n if savedUiState ~= nil then\n redDeckId = savedUiState.redDeck\n orangeDeckId = savedUiState.orangeDeck\n whiteDeckId = savedUiState.whiteDeck\n greenDeckId = savedUiState.greenDeck\n privateDeck = savedUiState.privateDeck\n loadNewestDeck = savedUiState.loadNewest\n loadInvestigators = savedUiState.investigators\n end\n\n makeOptionToggles()\n makeDeckIdFields()\n makeBuildButton()\nend\n\nfunction makeOptionToggles()\n -- common parameters\n local checkbox_parameters = {}\n checkbox_parameters.function_owner = self\n checkbox_parameters.width = INPUT_FIELD_WIDTH\n checkbox_parameters.height = INPUT_FIELD_HEIGHT\n checkbox_parameters.scale = { 0.1, 0.1, 0.1 }\n checkbox_parameters.font_size = 240\n checkbox_parameters.hover_color = { 0.4, 0.6, 0.8 }\n checkbox_parameters.color = FIELD_COLOR\n\n -- public / private deck\n checkbox_parameters.click_function = \"publicPrivateChanged\"\n checkbox_parameters.position = { 0.25, 0.1, -0.102 }\n checkbox_parameters.tooltip = \"Published or private deck?\\n\\nPLEASE USE A PRIVATE DECK IF JUST FOR TTS TO AVOID FLOODING ARKHAMDB PUBLISHED DECK LISTS!\"\n checkbox_parameters.label = PRIVATE_TOGGLE_LABELS[privateDeck]\n self.createButton(checkbox_parameters)\n\n -- load upgraded?\n checkbox_parameters.click_function = \"loadUpgradedChanged\"\n checkbox_parameters.position = { 0.25, 0.1, -0.01 }\n checkbox_parameters.tooltip = \"Load newest upgrade or exact deck?\"\n checkbox_parameters.label = UPGRADED_TOGGLE_LABELS[loadNewestDeck]\n self.createButton(checkbox_parameters)\n\n -- load investigators?\n checkbox_parameters.click_function = \"loadInvestigatorsChanged\"\n checkbox_parameters.position = { 0.25, 0.1, 0.081 }\n checkbox_parameters.tooltip = \"Spawn investigator cards?\"\n checkbox_parameters.label = LOAD_INVESTIGATOR_TOGGLE_LABELS[loadInvestigators]\n self.createButton(checkbox_parameters)\nend\n\n-- Create the four deck ID entry fields\nfunction makeDeckIdFields()\n local input_parameters = {}\n -- Parameters common to all entry fields\n input_parameters.function_owner = self\n input_parameters.scale = { 0.1, 0.1, 0.1 }\n input_parameters.width = INPUT_FIELD_WIDTH\n input_parameters.height = INPUT_FIELD_HEIGHT\n input_parameters.font_size = 320\n input_parameters.tooltip = \"Deck ID from ArkhamDB URL of the deck\\nPublic URL: 'https://arkhamdb.com/decklist/view/101/knowledge-overwhelming-solo-deck-1.0' = '101'\\nPrivate URL: 'https://arkhamdb.com/deck/view/102' = '102'\"\n input_parameters.alignment = 3 -- Center\n input_parameters.color = FIELD_COLOR\n input_parameters.font_color = { 0, 0, 0 }\n input_parameters.validation = 2 -- Integer\n\n -- Green\n input_parameters.input_function = \"greenDeckChanged\"\n input_parameters.position = { -0.166, 0.1, 0.385 }\n input_parameters.value = greenDeckId\n self.createInput(input_parameters)\n -- Red\n input_parameters.input_function = \"redDeckChanged\"\n input_parameters.position = { 0.171, 0.1, 0.385 }\n input_parameters.value = redDeckId\n self.createInput(input_parameters)\n -- White\n input_parameters.input_function = \"whiteDeckChanged\"\n input_parameters.position = { -0.166, 0.1, 0.474 }\n input_parameters.value = whiteDeckId\n self.createInput(input_parameters)\n -- Orange\n input_parameters.input_function = \"orangeDeckChanged\"\n input_parameters.position = { 0.171, 0.1, 0.474 }\n input_parameters.value = orangeDeckId\n self.createInput(input_parameters)\nend\n\n-- Create the Build All button. This is a transparent button which covers the Build All portion of the background graphic\nfunction makeBuildButton()\n local button_parameters = {}\n button_parameters.click_function = \"loadDecks\"\n button_parameters.function_owner = self\n button_parameters.position = { 0, 0.1, 0.71 }\n button_parameters.width = 320\n button_parameters.height = 30\n button_parameters.color = { 0, 0, 0, 0 }\n button_parameters.tooltip = \"Click to build all four decks!\"\n self.createButton(button_parameters)\nend\n\n-- Event handlers for deck ID change\nfunction redDeckChanged(_, _, inputValue) redDeckId = inputValue end\n\nfunction orangeDeckChanged(_, _, inputValue) orangeDeckId = inputValue end\n\nfunction whiteDeckChanged(_, _, inputValue) whiteDeckId = inputValue end\n\nfunction greenDeckChanged(_, _, inputValue) greenDeckId = inputValue end\n\n-- Event handlers for toggle buttons\nfunction publicPrivateChanged()\n privateDeck = not privateDeck\n self.editButton { index = 0, label = PRIVATE_TOGGLE_LABELS[privateDeck] }\nend\n\nfunction loadUpgradedChanged()\n loadNewestDeck = not loadNewestDeck\n self.editButton { index = 1, label = UPGRADED_TOGGLE_LABELS[loadNewestDeck] }\nend\n\nfunction loadInvestigatorsChanged()\n loadInvestigators = not loadInvestigators\n self.editButton { index = 2, label = LOAD_INVESTIGATOR_TOGGLE_LABELS[loadInvestigators] }\nend\n\nfunction loadDecks()\n -- testLoadLotsOfDecks()\n -- Method in DeckImporterMain, visible due to inclusion\n\n local indexReady = allCardsBagApi.isIndexReady()\n if (not indexReady) then\n broadcastToAll(\"Still loading player cards, please try again in a few seconds\", {0.9, 0.2, 0.2})\n return\n end\n if (redDeckId ~= nil and redDeckId ~= \"\") then\n buildDeck(\"Red\", redDeckId)\n end\n if (orangeDeckId ~= nil and orangeDeckId ~= \"\") then\n buildDeck(\"Orange\", orangeDeckId)\n end\n if (whiteDeckId ~= nil and whiteDeckId ~= \"\") then\n buildDeck(\"White\", whiteDeckId)\n end\n if (greenDeckId ~= nil and greenDeckId ~= \"\") then\n buildDeck(\"Green\", greenDeckId)\n end\nend\nend)\n__bundle_register(\"playercards/AllCardsBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local AllCardsBagApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getAllCardsBag()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"AllCardsBag\")\n end\n\n -- Returns a specific card from the bag, based on ArkhamDB ID\n ---@param id table String ID of the card to retrieve\n ---@return table table\n -- If the indexes are still being constructed, an empty table is\n -- returned. Otherwise, a single table with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardById = function(id)\n return getAllCardsBag().call(\"getCardById\", {id = id})\n end\n\n -- Gets a random basic weakness from the bag. Once a given ID has been returned\n -- it will be removed from the list and cannot be selected again until a reload\n -- occurs or the indexes are rebuilt, which will refresh the list to include all\n -- weaknesses.\n ---@return string: ID of the selected weakness.\n AllCardsBagApi.getRandomWeaknessId = function()\n return getAllCardsBag().call(\"getRandomWeaknessId\")\n end\n\n AllCardsBagApi.isIndexReady = function()\n return getAllCardsBag().call(\"isIndexReady\")\n end\n\n -- Called by Hotfix bags when they load. If we are still loading indexes, then\n -- the all cards and hotfix bags are being loaded together, and we can ignore\n -- this call as the hotfix will be included in the initial indexing. If it is\n -- called once indexing is complete it means the hotfix bag has been added\n -- later, and we should rebuild the index to integrate the hotfix bag.\n AllCardsBagApi.rebuildIndexForHotfix = function()\n return getAllCardsBag().call(\"rebuildIndexForHotfix\")\n end\n\n -- Searches the bag for cards which match the given name and returns a list. Note that this is\n -- an O(n) search without index support. It may be slow.\n ---@param name string or string fragment to search for names\n ---@param exact boolean Whether the name match should be exact\n AllCardsBagApi.getCardsByName = function(name, exact)\n return getAllCardsBag().call(\"getCardsByName\", {name = name, exact = exact})\n end\n\n AllCardsBagApi.isBagPresent = function()\n return getAllCardsBag() and true\n end\n\n -- Returns a list of cards from the bag matching a class and level (0 or upgraded)\n ---@param class string class to retrieve (\"Guardian\", \"Seeker\", etc)\n ---@param upgraded boolean true for upgraded cards (Level 1-5), false for Level 0\n ---@return table: If the indexes are still being constructed, returns an empty table.\n -- Otherwise, a list of tables, each with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded)\n return getAllCardsBag().call(\"getCardsByClassAndLevel\", {class = class, upgraded = upgraded})\n end\n\n AllCardsBagApi.getCardsByCycle = function(cycle)\n return getAllCardsBag().call(\"getCardsByCycle\", cycle)\n end\n\n AllCardsBagApi.getUniqueWeaknesses = function()\n return getAllCardsBag().call(\"getUniqueWeaknesses\")\n end\n\n return AllCardsBagApi\nend\nend)\n__bundle_register(\"playercards/PlayerCardSpawner\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Amount to shift for the next card (zShift) or next row of cards (xShift)\n-- Note that the table rotation is weird, and the X axis is vertical while the\n-- Z axis is horizontal\nlocal SPREAD_Z_SHIFT = -2.3\nlocal SPREAD_X_SHIFT = -3.66\n\nSpawner = { }\n\n-- Spawns a list of cards at the given position/rotation. This will separate cards by size -\n-- investigator, standard, and mini, spawning them in that order with larger cards on bottom. If\n-- there are different types, the provided callback will be called once for each type as it spawns\n-- either a card or deck.\n---@param cardList table A list of Player Card data structures (data/metadata)\n---@param pos tts__Vector table where the cards should be spawned (global)\n---@param rot tts__Vector table for the orientation of the spawned cards (global)\n---@param sort boolean True if this list of cards should be sorted before spawning\n---@param callback? function Callback to be called after the card/deck spawns.\nSpawner.spawnCards = function(cardList, pos, rot, sort, callback)\n if (sort) then\n table.sort(cardList, Spawner.cardComparator)\n end\n\n local miniCards = { }\n local standardCards = { }\n local investigatorCards = { }\n\n for _, card in ipairs(cardList) do\n if (card.metadata.type == \"Investigator\") then\n table.insert(investigatorCards, card)\n elseif (card.metadata.type == \"Minicard\") then\n table.insert(miniCards, card)\n else\n table.insert(standardCards, card)\n end\n end\n -- Spawn each of the three types individually. Each Y position shift accounts for the thickness\n -- of the spawned deck\n local position = { x = pos.x, y = pos.y, z = pos.z }\n Spawner.spawn(investigatorCards, position, rot, callback)\n\n position.y = position.y + (#investigatorCards + #standardCards) * 0.07\n Spawner.spawn(standardCards, position, rot, callback)\n\n position.y = position.y + (#standardCards + #miniCards) * 0.07\n Spawner.spawn(miniCards, position, rot, callback)\nend\n\nSpawner.spawnCardSpread = function(cardList, startPos, maxCols, rot, sort, callback)\n if (sort) then\n table.sort(cardList, Spawner.cardComparator)\n end\n\n local position = { x = startPos.x, y = startPos.y, z = startPos.z }\n -- Special handle the first row if we have less than a full single row, but only if there's a\n -- reasonable max column count. Single-row spreads will send a large value for maxCols\n if maxCols \u003c 100 and #cardList \u003c maxCols then\n position.z = startPos.z + ((maxCols - #cardList) / 2 * SPREAD_Z_SHIFT)\n end\n local cardsInRow = 0\n local rows = 0\n for _, card in ipairs(cardList) do\n Spawner.spawn({ card }, position, rot, callback)\n position.z = position.z + SPREAD_Z_SHIFT\n cardsInRow = cardsInRow + 1\n if cardsInRow \u003e= maxCols then\n rows = rows + 1\n local cardsForRow = #cardList - rows * maxCols\n if cardsForRow \u003e maxCols then\n cardsForRow = maxCols\n end\n position.z = startPos.z + ((maxCols - cardsForRow) / 2 * SPREAD_Z_SHIFT)\n position.x = position.x + SPREAD_X_SHIFT\n cardsInRow = 0\n end\n end\nend\n\n-- Spawn a specific list of cards. This method is for internal use and should not be called\n-- directly, use spawnCards instead.\n---@param cardList table A list of Player Card data structures (data/metadata)\n---@param pos table Position where the cards should be spawned (global)\n---@param rot table Rotation for the orientation of the spawned cards (global)\n---@param callback? function callback to be called after the card/deck spawns.\nSpawner.spawn = function(cardList, pos, rot, callback)\n if #cardList == 0 then return end\n\n -- Spawn a single card directly\n if #cardList == 1 then\n -- handle sideways card\n if cardList[1].data.SidewaysCard then\n rot = { rot.x, rot.y - 90, rot.z }\n end\n spawnObjectData({\n data = cardList[1].data,\n position = pos,\n rotation = rot,\n callback_function = callback\n })\n return\n end\n\n -- For multiple cards, construct a deck and spawn that\n local deck = Spawner.buildDeckDataTemplate()\n\n -- Decks won't inherently scale to the cards in them. The card list being spawned should be all\n -- the same type/size by this point, so use the first card to set the size\n deck.Transform = {\n scaleX = cardList[1].data.Transform.scaleX,\n scaleY = 1,\n scaleZ = cardList[1].data.Transform.scaleZ\n }\n\n local sidewaysDeck = true\n for _, spawnCard in ipairs(cardList) do\n Spawner.addCardToDeck(deck, spawnCard.data)\n -- set sidewaysDeck to false if any card is not a sideways card\n sidewaysDeck = (sidewaysDeck and spawnCard.data.SidewaysCard)\n end\n\n -- set the alt view angle for sideways decks\n if sidewaysDeck then\n deck.AltLookAngle = { x = 0, y = 180, z = 90 }\n rot = { rot.x, rot.y - 90, rot.z }\n end\n\n spawnObjectData({\n data = deck,\n position = pos,\n rotation = rot,\n callback_function = callback\n })\nend\n\n-- Inserts a card into the given deck. This does three things:\n-- 1. Add the card's data to ContainedObjects\n-- 2. Add the card's ID (the TTS CardID, not the Arkham ID) to the deck's\n-- ID list. Note that the deck's ID list is \"DeckIDs\" even though it\n-- contains a list of card Ids\n-- 3. Extract the card's CustomDeck table and add it to the deck. The deck's\n-- \"CustomDeck\" field is a list of all CustomDecks used by cards within the\n-- deck, keyed by the DeckID and referencing the custom deck table\n---@param deck table TTS deck data structure to add to\n---@param cardData table Data for the card to be inserted\nSpawner.addCardToDeck = function(deck, cardData)\n for customDeckId, customDeckData in pairs(cardData.CustomDeck) do\n if (deck.CustomDeck[customDeckId] == nil) then\n -- CustomDeck not added to deck yet, add it\n deck.CustomDeck[customDeckId] = customDeckData\n elseif (deck.CustomDeck[customDeckId].FaceURL == customDeckData.FaceURL) then\n -- CustomDeck for this card matches the current one for the deck, do nothing\n else\n -- CustomDeck data conflict\n local newDeckId = nil\n for deckId, customDeck in pairs(deck.CustomDeck) do\n if (customDeckData.FaceURL == customDeck.FaceURL) then\n newDeckId = deckId\n end\n end\n if (newDeckId == nil) then\n -- No non-conflicting custom deck for this card, add a new one\n newDeckId = Spawner.findNextAvailableId(deck.CustomDeck, \"1000\")\n deck.CustomDeck[newDeckId] = customDeckData\n end\n -- Update the card with the new CustomDeck info\n cardData.CardID = newDeckId..string.sub(cardData.CardID, 5)\n cardData.CustomDeck[customDeckId] = nil\n cardData.CustomDeck[newDeckId] = customDeckData\n break\n end\n end\n table.insert(deck.ContainedObjects, cardData)\n table.insert(deck.DeckIDs, cardData.CardID)\nend\n\n-- Create an empty deck data table which can have cards added to it. This\n-- creates a new table on each call without using metatables or previous\n-- definitions because we can't be sure that TTS doesn't modify the structure\n---@return table deck Table containing the minimal TTS deck data structure\nSpawner.buildDeckDataTemplate = function()\n local deck = {}\n deck.Name = \"Deck\"\n\n -- Card data. DeckIDs and CustomDeck entries will be built from the cards\n deck.ContainedObjects = {}\n deck.DeckIDs = {}\n deck.CustomDeck = {}\n\n -- Transform is required, Position and Rotation will be overridden by the spawn call so can be omitted here\n deck.Transform = {\n scaleX = 1,\n scaleY = 1,\n scaleZ = 1,\n }\n\n return deck\nend\n\n-- Returns the first ID which does not exist in the given table, starting at startId and increasing\n---@param objectTable table keyed by strings which are numbers\n---@param startId string possible ID.\n---@return string id \u003e= startId\nSpawner.findNextAvailableId = function(objectTable, startId)\n local id = startId\n while (objectTable[id] ~= nil) do\n id = tostring(tonumber(id) + 1)\n end\n return id\nend\n\n-- Get the PBCN (Permanent/Bonded/Customizable/Normal) value from the given metadata.\n---@return number PBCN 1 for Permanent, 2 for Bonded or 4 for Normal. The actual values are\n-- irrelevant as they provide only grouping and the order between them doesn't matter.\nSpawner.getpbcn = function(metadata)\n if metadata.permanent then\n return 1\n elseif metadata.bonded_to ~= nil then\n return 2\n else -- Normal card\n return 3\n end\nend\n\n-- Comparison function used to sort the cards in a deck. Groups bonded or\n-- permanent cards first, then sorts within theose types by name/subname.\n-- Normal cards will sort in standard alphabetical order, while\n-- permanent/bonded/customizable will be in reverse alphabetical order.\n--\n-- Since cards spawn in the order provided by this comparator, with the first\n-- cards ending up at the bottom of a pile, this ordering will spawn in reverse\n-- alphabetical order. This presents the cards in order for non-face-down\n-- areas, and presents them in order when Searching the face-down deck.\nSpawner.cardComparator = function(card1, card2)\n local pbcn1 = Spawner.getpbcn(card1.metadata)\n local pbcn2 = Spawner.getpbcn(card2.metadata)\n if pbcn1 ~= pbcn2 then\n return pbcn1 \u003e pbcn2\n end\n if pbcn1 == 3 then\n if card1.data.Nickname ~= card2.data.Nickname then\n return card1.data.Nickname \u003c card2.data.Nickname\n end\n return card1.data.Description \u003c card2.data.Description\n else\n if card1.data.Nickname ~= card2.data.Nickname then\n return card1.data.Nickname \u003e card2.data.Nickname\n end\n return card1.data.Description \u003e card2.data.Description\n end\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "{\"greenDeck\":\"\",\"investigators\":true,\"loadNewest\":true,\"orangeDeck\":\"\",\"privateDeck\":true,\"redDeck\":\"\",\"whiteDeck\":\"\"}", "MeasureMovement": false, "Name": "Custom_Tile", @@ -88528,7 +88538,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"util/ConnectionDrawingTool\")\nend)\n__bundle_register(\"util/ConnectionDrawingTool\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal lines = {}\n\n-- save \"lines\" to be able to remove them after loading\nfunction onSave()\n return JSON.encode(lines)\nend\n\nfunction onLoad(savedData)\n lines = JSON.decode(savedData) or {}\nend\n\n-- create timer when numpad 0 is pressed\nfunction onScriptingButtonDown(index, player_color)\n if index ~= 10 then return end\n TimerID = Wait.time(function() draw_from(Player[player_color]) end, 1)\nend\n\n-- called for long press of numpad 0, draws lines from hovered object to selected objects\nfunction draw_from(player)\n local source = player.getHoverObject()\n if not source then return end\n\n for _, item in ipairs(player.getSelectedObjects()) do\n if item.getGUID() ~= source.getGUID() then\n if item.getGUID() \u003e source.getGUID() then\n draw_with_pair(item, source)\n else\n draw_with_pair(source, item)\n end\n end\n end\n\n process_lines()\nend\n\n-- general drawing of all lines between selected objects\nfunction onScriptingButtonUp(index, player_color)\n if index ~= 10 then return end\n -- returns true only if there is a timer to cancel. If this is false then we've waited longer than a second.\n if not Wait.stop(TimerID) then return end\n\n local items = Player[player_color].getSelectedObjects()\n if #items \u003c 2 then\n broadcastToColor(\"You must have at least two items selected (currently: \" .. #items .. \").\", player_color, \"Red\")\n return\n end\n\n table.sort(items, function(a, b) return a.getGUID() \u003e b.getGUID() end)\n\n for f = 1, #items - 1 do\n for s = f + 1, #items do\n draw_with_pair(items[f], items[s])\n end\n end\n\n process_lines()\nend\n\n-- adds two objects to table of vector lines\nfunction draw_with_pair(first, second)\n local guid_first = first.getGUID()\n local guid_second = second.getGUID()\n\n if Global.getVectorLines() == nil then lines = {} end\n if not lines[guid_first] then lines[guid_first] = {} end\n\n if lines[guid_first][guid_second] then\n lines[guid_first][guid_second] = nil\n else\n lines[guid_first][guid_second] = { points = { first.getPosition(), second.getPosition() }, color = \"White\" }\n end\nend\n\n-- updates the global vector lines based on \"lines\"\nfunction process_lines()\n local drawing = {}\n\n for _, first in pairs(lines) do\n for _, data in pairs(first) do\n table.insert(drawing, data)\n end\n end\n\n Global.setVectorLines(drawing)\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"util/ConnectionDrawingTool\")\nend)\n__bundle_register(\"util/ConnectionDrawingTool\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal lines = {}\n\n-- save \"lines\" to be able to remove them after loading\nfunction onSave()\n return JSON.encode(lines)\nend\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n lines = JSON.decode(savedData) or {}\n end\nend\n\n-- create timer when numpad 0 is pressed\nfunction onScriptingButtonDown(index, player_color)\n if index ~= 10 then return end\n TimerID = Wait.time(function() draw_from(Player[player_color]) end, 1)\nend\n\n-- called for long press of numpad 0, draws lines from hovered object to selected objects\nfunction draw_from(player)\n local source = player.getHoverObject()\n if not source then return end\n\n for _, item in ipairs(player.getSelectedObjects()) do\n if item.getGUID() ~= source.getGUID() then\n if item.getGUID() \u003e source.getGUID() then\n draw_with_pair(item, source)\n else\n draw_with_pair(source, item)\n end\n end\n end\n\n process_lines()\nend\n\n-- general drawing of all lines between selected objects\nfunction onScriptingButtonUp(index, player_color)\n if index ~= 10 then return end\n -- returns true only if there is a timer to cancel. If this is false then we've waited longer than a second.\n if not Wait.stop(TimerID) then return end\n\n local items = Player[player_color].getSelectedObjects()\n if #items \u003c 2 then\n broadcastToColor(\"You must have at least two items selected (currently: \" .. #items .. \").\", player_color, \"Red\")\n return\n end\n\n table.sort(items, function(a, b) return a.getGUID() \u003e b.getGUID() end)\n\n for f = 1, #items - 1 do\n for s = f + 1, #items do\n draw_with_pair(items[f], items[s])\n end\n end\n\n process_lines()\nend\n\n-- adds two objects to table of vector lines\nfunction draw_with_pair(first, second)\n local guid_first = first.getGUID()\n local guid_second = second.getGUID()\n\n if Global.getVectorLines() == nil then lines = {} end\n if not lines[guid_first] then lines[guid_first] = {} end\n\n if lines[guid_first][guid_second] then\n lines[guid_first][guid_second] = nil\n else\n lines[guid_first][guid_second] = { points = { first.getPosition(), second.getPosition() }, color = \"White\" }\n end\nend\n\n-- updates the global vector lines based on \"lines\"\nfunction process_lines()\n local drawing = {}\n\n for _, first in pairs(lines) do\n for _, data in pairs(first) do\n table.insert(drawing, data)\n end\n end\n\n Global.setVectorLines(drawing)\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "{\"e8e04b\":[]}", "MeasureMovement": false, "Name": "Custom_Token", @@ -88585,7 +88595,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/PlayAreaSelector\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/PlayAreaImageData\", function(require, _LOADED, __bundle_register, __bundle_modules)\nPLAYAREA_IMAGE_DATA = {\n [\"Official Campaigns\"] = {\n [\"Night of the Zealot\"] = {\n {\n Name = \"I - The Gathering 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725443007/D34B55D2637EF1DF22839D12F9CF74F92F8EB486/\"\n },\n {\n Name = \"III - The Devourer Below 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725443203/FBE04C8B89F79D18C6D29C28DC3B292A5A3A3DEB/\"\n },\n {\n Name = \"III - The Devourer Below 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725443345/FD10BC04B3F3AFD710C3C12EE14F85F9AFB265E6/\"\n }\n },\n [\"The Dunwich Legacy\"] = {\n {\n Name = \"I-A - Extracurricular Activity 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725401398/AC55F0754B7E4A39796A6F2236012AE03DA55E20/\"\n },\n {\n Name = \"I-A - Extracurricular Activity 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725401658/9F3ED6E256818C4528D55980B9D7E44B87170A4F/\"\n },\n {\n Name = \"I-A - Extracurricular Activity 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725401870/FE29404D9D93BE2735D41C115DDD9708A0931F3E/\"\n },\n {\n Name = \"I-B - The House Always Wins 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725402059/4C4A50D259ECFD4DFB94FABB9FA2AD3AABDCA0CA/\"\n },\n {\n Name = \"I-B - The House Always Wins 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725402263/8B0C981B78E803B3BFD64AC874F315B6810E579B/\"\n },\n {\n Name = \"I-B - The House Always Wins 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725402460/8599D17306C644D75D189591BC6D57C2F27F9E35/\"\n },\n {\n Name = \"I-B - The House Always Wins 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725402641/777865B25BCF86C2EFEAE232AFBC31561D12AE0F/\"\n },\n {\n Name = \"II - The Miskatonic Museum 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725402804/A44E68AC08E6568A757429B29E71C703B76FA159/\"\n },\n {\n Name = \"II - The Miskatonic Museum 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725403000/B28D46D5B7BCE9EA9BF27D3A0A932393D8258A76/\"\n },\n {\n Name = \"III - The Essex County Express\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725403150/956BE4B5C25805E57C8FC5CF28A94BD7EF07CA54/\"\n },\n {\n Name = \"IV - Blood on the Altar 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725403290/07DD1508BA880AD1212A820BC29471C48DC90C53/\"\n },\n {\n Name = \"IV - Blood on the Altar 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725403456/A74398E8CCD78657C2555832A3B340723E8C9117/\"\n },\n {\n Name = \"IV - Blood on the Altar 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725403636/CD89D7D9CC020F41D5AD02D54E308877583EC45F/\"\n },\n {\n Name = \"IV - Blood on the Altar 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725403818/AEFAC50DAC82271BCACC53B8FF69B5B094FA1078/\"\n },\n {\n Name = \"V - Undimensioned and Unseen 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725403955/E7C566E536CF6E910DB654FC1DBF4838F2BAF899/\"\n },\n {\n Name = \"V - Undimensioned and Unseen 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725404127/F92F123BBD3D857C579B9284988C3AFFBCD84B2B/\"\n },\n {\n Name = \"V - Undimensioned and Unseen 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725404273/7F8CFE6785BD74BB8D5E34C204AFB8AA580CA3E3/\"\n },\n {\n Name = \"V - Undimensioned and Unseen 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725404424/C2AE08371CF2DE2777791BBD4AEF446E50532382/\"\n },\n {\n Name = \"VI - Where Doom Awaits 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725404578/A520CE0F6B0C8591A48ADEF34E68B46AFC2BC83B/\"\n },\n {\n Name = \"VI - Where Doom Awaits 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725404740/1FF9EF375BDBB73CA8F0A1562F215692AAEA7131/\"\n },\n {\n Name = \"VI - Where Doom Awaits 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725404914/5473D20CE0122F55EEADB16C4353D4EDD91E440E/\"\n },\n {\n Name = \"VI - Where Doom Awaits 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725405088/A0AA8CB864747152763D434D0737D81EB515E71B/\"\n },\n {\n Name = \"VI - Where Doom Awaits 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725405247/FAF408DAAD4FC72142DFDFE5FCEA4B84293AA72C/\"\n },\n {\n Name = \"VII - Lost in Time and Space 1\",\n URL = \"https://i.ibb.co/rtTpbDx/Dunwich-8-Lost-in-Time-amp-Space.jpg\"\n },\n {\n Name = \"VII - Lost in Time and Space 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725405746/771BAE40F98BB16F8D011FA794E4AC0095131AF1/\"\n },\n {\n Name = \"VII - Lost in Time and Space 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725406148/D15D56EA34F27C651D7E7AC202DA4DEBE395E310/\"\n }\n },\n [\"The Path to Carcosa\"] = {\n {\n Name = \"I - Curtain Call\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725426327/41F6192EDCFFD6AAE2EE44C2BB5708B19D7464A9/\"\n },\n {\n Name = \"II - The Last King 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725426499/114EAEA245AC51CA219364AF26341E7F7E649A7D/\"\n },\n {\n Name = \"II - The Last King 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725426683/A2762E95DD79D7A7BC749925166BBFC18B62EF3B/\"\n },\n {\n Name = \"II - The Last King 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725426818/A6A20773EA95CE3D9896B22E317A0E1ACCA911F0/\"\n },\n {\n Name = \"III - Echoes of the Past\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725427005/25F51DE4B1F33C16A0E68C929E5002F0C4520A37/\"\n },\n {\n Name = \"IV - The Unspeakable Oath 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725427178/9575E4F6E53DDAD2D3E61684AB9757B04E1EF787/\"\n },\n {\n Name = \"IV - The Unspeakable Oath 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725427342/199A6C6411992ACFB8A417E86207FE6CE956EB97/\"\n },\n {\n Name = \"IV - The Unspeakable Oath 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725427501/48525BCDFA281947FA9ED26507BC1F81C07056E8/\"\n },\n {\n Name = \"V - A Phantom of Truth 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725427681/F72B02FF1A5E58CBCB0E53C8455310AF37064477/\"\n },\n {\n Name = \"V - A Phantom of Truth 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725427848/215A757FF28317EB3EF7CF1F9CAE6F1CFF735091/\"\n },\n {\n Name = \"VI - The Pallid Mask 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725428067/D46BAD80B112156A2D3DEFF247A74C74F27DDA12/\"\n },\n {\n Name = \"VI - The Pallid Mask 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725428250/464681CF59770BFD493A0D672C7CB70BA8CD3499/\"\n },\n {\n Name = \"VII - Black Stars Rise 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725428431/4766E1A4893E0EF16B576749B73CE449F10DA20C/\"\n },\n {\n Name = \"VII - Black Stars Rise 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725428896/05ED3D08F29C8E6EC080F0615DE130F2A687A9AC/\"\n },\n {\n Name = \"VIII - Dim Carcosa 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725429052/BA81DBDE7A12B993CB8B7001CA93095AD0512449/\"\n },\n {\n Name = \"VIII - Dim Carcosa 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725429235/C5C939E0213575B5EDCA6723D209892071DDE4B5/\"\n }\n },\n [\"The Forgotten Age\"] = {\n {\n Name = \"I - The Untamed Wilds 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725446729/7F5E48BC9A028AE5117231364F2D5B433A62239A/\"\n },\n {\n Name = \"I - The Untamed Wilds 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725446946/55C374DC5BE3620CB0D5BCA379EA55CF471D09B3/\"\n },\n {\n Name = \"I - The Untamed Wilds 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725447172/6EAE2CFD3AC552CFB744C75E4E26A79264DE17D3/\"\n },\n {\n Name = \"I - The Untamed Wilds 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725447409/FCF48C94D90F94FBFFD674B0650E288E7312C441/\"\n },\n {\n Name = \"I - The Untamed Wilds 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725447579/F7C3FB9E31147430C1384684887FC66E616D0302/\"\n },\n {\n Name = \"II - The Doom of Eztli 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725447752/44EF68E1BF3C2D9DCD5306DD90B4CCCFBE03891C/\"\n },\n {\n Name = \"II - The Doom of Eztli 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725448027/F5F14EC590C33BC87D8F0CFF43D7E4DF80D61133/\"\n },\n {\n Name = \"II - The Doom of Eztli 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725448215/BFD9D940DB8EC9AC8D818C48BBAE3338A8E48A3B/\"\n },\n {\n Name = \"III - Threads of Fate\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725448393/67F3BE7DC1BEC807A17D3F8914328D408856E019/\"\n },\n {\n Name = \"IV - The Boundary Beyond 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725448568/3C268415A47430CEEC3F9BFB216EF57E3DBF820A/\"\n },\n {\n Name = \"IV - The Boundary Beyond 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725448701/3FA23DCA30505AD4C27D8914740AD3138C01122C/\"\n },\n {\n Name = \"IV - The Boundary Beyond 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725448863/266C3320AC326C30F08FBC11A95567E1249E7FB7/\"\n },\n {\n Name = \"V - Heart of the Elders 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725449019/A6CC459ACA004C33DD9605BE8382437F6BBE24F7/\"\n },\n {\n Name = \"V - Heart of the Elders 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725449150/241FA88572B6B4F652D7FC6D1EDB23DF94E3199C/\"\n },\n {\n Name = \"V - Heart of the Elders 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725449310/DBD731498FAB399A4155F7B64F8710BF5FBB5C1F/\"\n },\n {\n Name = \"VI - The City of Archives 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725449473/527CB6470F508D4E1F1E4AFC8A0D3AB0A65E046E/\"\n },\n {\n Name = \"VI - The City of Archives 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725449630/A8E933F79A646990155CC18A2143B3BC16222750/\"\n },\n {\n Name = \"VI - The City of Archives 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725449814/30BB7E4F8D9F1571A420372E78ACAF2D7792811F/\"\n },\n {\n Name = \"VII - The Depths of Yoth 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725449962/D69532827DFF2D654F8A606B7917D593F52D7624/\"\n },\n {\n Name = \"VII - The Depths of Yoth 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725450085/479A8A1BDD7BE80B43AE4F2C14DFA811D7B28482/\"\n },\n {\n Name = \"VII - The Depths of Yoth 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725450258/E617F5A78DFBE913652E20BF97D38B91087FACAE/\"\n },\n {\n Name = \"VIII - Shattered Aeons 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725450415/5631152D4830C00DB8D8EB2163CE773542A62C79/\"\n },\n {\n Name = \"VIII - Shattered Aeons 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725450556/C3000D020B0C32B4DA3420AEE5E286893453FC49/\"\n }\n },\n [\"The Circle Undone\"] = {\n {\n Name = \"0 - Disappearance at the Twilight Estate\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725457506/6E228F87CEDCD3A0CFA28B680C266B4C68C7682B/\"\n },\n {\n Name = \"I - The Witching Hour\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725457706/D0FDC0E9287C343745AE6135352194D654D98B64/\"\n },\n {\n Name = \"II - At Death's Doorstep 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725457864/3106851EC93B1FC01311BD68F02145BA2FD720B0/\"\n },\n {\n Name = \"II - At Death's Doorstep 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725458037/155EB572CF28F09A64A021CAC3A3219C31B2CD49/\"\n },\n {\n Name = \"II - At Death's Doorstep 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725458187/482CC6730F267061A055D6FD402603BC642A9635/\"\n },\n {\n Name = \"III - The Secret Name 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725458373/769D67103FACFB94E77465E85DBB2A250284B59B/\"\n },\n {\n Name = \"III - The Secret Name 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725458592/D70CE9B1AD7158AF206A25777A8BA6F284587A83/\"\n },\n {\n Name = \"III - The Secret Name 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725458848/2FC0D5AFFA97AB5E80244F1ED711036B2149B0EE/\"\n },\n {\n Name = \"III - The Secret Name 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459026/A1A5B18ECB38985A35781CBDFF53935541720AF4/\"\n },\n {\n Name = \"IV - The Wages of Sin 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459182/46870E1DBE623E93E675CB2D3C1E959B40CDCC83/\"\n },\n {\n Name = \"IV - The Wages of Sin 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459344/9552699A8CEC5E7BF22843990394BB977539CBE0/\"\n },\n {\n Name = \"IV - The Wages of Sin 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459466/9B6B55A6F76668929B6D6B1DD5FDAE7CEE427A1C/\"\n },\n {\n Name = \"IV - The Wages of Sin 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459609/054A60BDCD266C1A53F29067CFC83D0561666FE4/\"\n },\n {\n Name = \"IV - Wages of Sin 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459714/11B3D734AC5229A0DEA5372CD50F5C7841F9D5A0/\"\n },\n {\n Name = \"V - For the Greater Good 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459829/9AA9563CCD72A8593BDE3C6D1299E96325ECE747/\"\n },\n {\n Name = \"V - For the Greater Good 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459933/13A103B7BC0ABB611F6A8E61D033C6AD95EED4D4/\"\n },\n {\n Name = \"V - For the Greater Good 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725460088/C88DDC5CE898ACEF360B8AD72E05F15BF84DE171/\"\n },\n {\n Name = \"V - For the Greater Good 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725460182/C086EDA78636624FC9C4EA1DBCD8F1D39B7A6A89/\"\n },\n {\n Name = \"VI - Union and Disillusioned\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725460382/8EFB842A623A2D1E6D0E915268A207A5D7DFC6D4/\"\n },\n {\n Name = \"VII - In the Clutches of Chaos 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725460586/7E156BF93F211BC425CD37ED273FCC84FF1F4C4D/\"\n },\n {\n Name = \"VII - In the Clutches of Chaos 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725460740/72A39A0FACA806EF2E0A4E31AEDF6D8FCDF1A876/\"\n },\n {\n Name = \"VII - In the Clutches of Chaos 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725460884/5716F6E2CB3F8D14FA5B7B806555896088696057/\"\n },\n {\n Name = \"VIII - Before the Black Throne 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725461042/DFF7A992A9440E58CE32D4B8A96A02A8F785AC90/\"\n },\n {\n Name = \"VIII - Before the Black Throne 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725461161/18902B2F74C9D70F5EA79A34521E3FDEDEFC893D/\"\n }\n },\n [\"The Dream-Eaters\"] = {\n {\n Name = \"I-A - Beyond the Gates of Sleep 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725465733/828EE1FF16928EA0426BC68AAED4B9AA6B6FBB49/\"\n },\n {\n Name = \"I-A - Beyond the Gates of Sleep 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725465934/35A85E9056B7A212AC39E7043FDF546A425E62F2/\"\n },\n {\n Name = \"I-A - Beyond the Gates of Sleep 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725466105/05D29313D2559B6683465A7034DE7B07DE675420/\"\n },\n {\n Name = \"I-B - Waking Nightmare\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725466267/16FAE20612ED0A6A65836DD1B014AC5A801A172F/\"\n },\n {\n Name = \"II-A - The Search for Kadath 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725466425/03CCD5F24999CC6CC905CB2FD021DB67D7769163/\"\n },\n {\n Name = \"II-A - The Search for Kadath 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725466615/085ACE95FEF03D2BE91BAD5E1864E1D0263DCCC0/\"\n },\n {\n Name = \"II-A - The Search for Kadath 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725466802/83861733568FCA9673B6F5EFE0C9D3337E3DFD27/\"\n },\n {\n Name = \"II-A - The Search for Kadath 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725466941/D4FDE1FE722DC6B03AD38D797F2E00531908583D/\"\n },\n {\n Name = \"II-A - The Search for Kadath 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725467396/C9A476395B9326142BBDBD06D22A14C83EAD2161/\"\n },\n {\n Name = \"II-B - A Thousand Shapes of Horror 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725467582/5EB69F3A3F20B312FE3FE3C64FEA96200EE51563/\"\n },\n {\n Name = \"II-B - A Thousand Shapes of Horror 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725467791/5FE437C821641EDD703D336205A37F8F0CACFD38/\"\n },\n {\n Name = \"II-B - A Thousand Shapes of Horror 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725467946/841CEC1D8B56C1CA52B5558E8E49CE04D95D2F4A/\"\n },\n {\n Name = \"III-A - Dark Side of the Moon 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725468100/2DD1038163AD5DAA759EA4BE49DB82A2718E931F/\"\n },\n {\n Name = \"III-A - Dark Side of the Moon 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725468293/E8145D05833864EEC70AF9AC401039D8E8AFDE3E/\"\n },\n {\n Name = \"III-B - Point of No Return 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725468506/1F2E3D425A4D97ADBCA59B4A9401C411F91F875F/\"\n },\n {\n Name = \"III-B - Point of No Return 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725468694/8631E68BA7CE69BECF1D476A03CBDC79112A60BF/\"\n },\n {\n Name = \"IV-A - Where the Gods Dwell\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725468880/2C8A9459149D33E526FDC4B68A063475305C15F8/\"\n },\n {\n Name = \"IV-B - Weaver of the Cosmos 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725469060/9E6AF9E0D68EC0F44B82968CE99E433A25A0E0C4/\"\n },\n {\n Name = \"IV-B - Weaver of the Cosmos 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725469224/8C969B8ABAEE6CFFEF165C2E4BBA0E7E9B33AA1A/\"\n },\n {\n Name = \"IV-B - Weaver of the Cosmos 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725469417/A94C14A64836FB9B5FAFAC5B790C51441F8D475F/\"\n }\n },\n [\"The Innsmouth Conspiracy\"] = {\n {\n Name = \"I - The Pit of Despair 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725473070/57FEAA8135F62DBAD52E2AAB562EF45EB9A0194A/\"\n },\n {\n Name = \"I - The Pit of Despair 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725473257/FEC6F9FAA1CC656BFD5861F58E4751BC94AB0424/\"\n },\n {\n Name = \"II - The Vanishing of Elina Harper 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725473424/B0E2BFA9C7F61A5B7A72CD11AD1AFF4A070AFFA1/\"\n },\n {\n Name = \"II - The Vanishing of Elina Harper 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725473570/D28C2DA099D656116A0D7BAA8B874E4ED6B6B50E/\"\n },\n {\n Name = \"II - The Vanishing of Elina Harper 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725473731/EE9BED3522A1B7CD5E394A67AD7F692DB709A9B5/\"\n },\n {\n Name = \"II - The Vanishing of Elina Harper 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725473874/0A85B2CE9A3FFB048C932E1B014B2986D5D42A1B/\"\n },\n {\n Name = \"II - Vanishing of Elina Harper 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725474056/C82E467216DF747AA954C614D7D0B8F649163EDA/\"\n },\n {\n Name = \"III - In Too Deep 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725474234/C6A72CDEFCDF1F2A3C6036F349B5F368EFDACA2E/\"\n },\n {\n Name = \"III - In Too Deep 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725474398/752D0CE313C58A5B1C3181503C841EB91D041492/\"\n },\n {\n Name = \"III - In Too Deep 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725474562/308687DFB9B0F2286A9248698FD38C0BF66B89ED/\"\n },\n {\n Name = \"IV - Devil Reef 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725474717/DCEC44D2F7F22A950B3CF52C81C8F931710EFADC/\"\n },\n {\n Name = \"IV - Devil Reef 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725474883/04913E71194BF766DFF2DF8646251AC461A35FE2/\"\n },\n {\n Name = \"V - Horror in High Gear 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725475029/FAA34C92FA800E8DDF6449B1C48FCC7468D783BD/\"\n },\n {\n Name = \"V - Horror in High Gear 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725475133/BC689B58040F74E7DB44CFD8F3F2BF32FE4081E1/\"\n },\n {\n Name = \"V - Horror in High Gear 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725475307/53ADF5E957F88F1DDCE46828547E5808C3CAEFD7/\"\n },\n {\n Name = \"V - Horror in High Gear 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725475402/C41EB1D2F8549669DD4323A339F5EC594996816C/\"\n },\n {\n Name = \"VI - A Light in the Fog 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725475509/C526C9A3AC34195ACF6161D4821D1424A8A288B4/\"\n },\n {\n Name = \"VI - A Light in the Fog 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725475660/2C67D57967F300BD1FE1AFC08C49EBCF4A88D11C/\"\n },\n {\n Name = \"VII - The Lair of Dagon 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725476055/4BC221648012F7A7A37B2F65929705E973FF9CE3/\"\n },\n {\n Name = \"VII - The Lair of Dagon 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725476271/3F9CF0FE8ACCE12E26ACA5D5777177A10B49D6DA/\"\n },\n {\n Name = \"VIII - Into the Maelstrom 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725476474/AF8695342FBCE6F6BC7B353C86C6006F1629F43A/\"\n },\n {\n Name = \"VIII - Into the Maelstrom 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725476643/CB175401ECDF04F97334CBF8AE7EC76A43A85735/\"\n }\n },\n [\"Edge of the Earth\"] = {\n {\n Name = \"I - Ice and Death 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725482152/322E07021DC78455859C860D8B1574F1BA2E0F68/\"\n },\n {\n Name = \"I - Ice and Death 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725482327/BD14DDE856A2062A939F860743FFF15F8B0BFF5A/\"\n },\n {\n Name = \"I - Ice and Death 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725482520/0FB5AC83DF448994EC0A866ACF6AF57ADCC59C82/\"\n },\n {\n Name = \"??? - Fatal Mirage\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725481929/A35EDF11BD6AF52784BA6611C363CBBB373622EE/\"\n },\n {\n Name = \"II - To the Forbidden Peaks 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725482688/B50455616DFC14FE0B9398DBE2A3A1AE25040516/\"\n },\n {\n Name = \"II - To the Forbidden Peaks 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725482839/17786225AA56E75E558491E7E710F555AF3E5799/\"\n },\n {\n Name = \"III - City of the Elder Things 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725483014/B74378E02A1A99F544CD98141EF62193A2A612FB/\"\n },\n {\n Name = \"III - City of the Elder Things 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725483208/CDFF7A2D404485DE2B4C4ED54B34E197515F0094/\"\n },\n {\n Name = \"IV - The Heart of Madness 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725483349/A96BC4AA73C71FE86EF38110236BAEF710C00EE2/\"\n },\n {\n Name = \"IV - The Heart of Madness 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725483528/5BF0DD740C5D43EFBFEF0436EB35FF9DA748FA5E/\"\n }\n },\n [\"The Scarlet Keys\"] = {\n {\n Name = \"5-A Riddles and Rain\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2037357792057358580/E9E5FE4028C08B3D4883406821221B73C8B5B2C7/\"\n },\n {\n Name = \"11-B Dead Heat\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2038485431566443853/CAD7771D90141EA6D5FFAFE1EC5E7AD9647C82DB/\"\n },\n {\n Name = \"16-D Sanguine Shadows\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2037357792057358704/4A7261EB31511467CBC46E876476DD205F528A4B/\"\n },\n {\n Name = \"21-F Dealings in the Dark\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2037357792057358816/7C9FE4C34CD0A7AE87EF054742D878F310C71AA7/\"\n },\n {\n Name = \"28-I Dancing Mad\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2037357792056955518/EAB857DD5629EC6A3078FB0A3A703B85B5F514B9/\"\n },\n {\n Name = \"23-K On Thin Ice\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2038485431566444026/EB5628E254AE25DA89A9C999EAAD995ECF67068E/\"\n },\n {\n Name = \"38-N Dogs of War\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2038485431566444199/194FD9A713907197471A55411AE300B62C5F5278/\"\n },\n {\n Name = \"46-Q Shades of Suffering\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2038485431566444330/3ED2CCE95DE933546E1B5CBBF445D773E6D65465/\"\n },\n {\n Name = \"56-Y Without a Trace\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2038485431566444450/FE4C335B0F72E83900A4EED0FD1A1D304D70D6B7/\"\n },\n {\n Name = \"59-Z Congress of the Keys 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2038485431566444576/5BB32469ED412D59BB0A46E57D226500B1D0568B/\"\n },\n {\n Name = \"59-Z Congress of the Keys 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2038485431566444690/B01A1FEAB57473D9B6DF11B92D62C214AA1C2C02/\"\n }\n }\n },\n [\"Official Scenarios\"] = {\n [\"The Blob That Ate Everything\"] = {\n {\n Name = \"The Blob That Ate Everything 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725489144/53A920E2D1A9F41937B21B0A5B1A4E450ABFC460/\"\n },\n {\n Name = \"The Blob That Ate Everything 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725488396/9CC07F923BD1CBFC4BB06DD2CC6747D2C3541737/\"\n }\n },\n [\"Carnevale of Horrors\"] = {\n {\n Name = \"Carnevale of Horrors 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725496678/91164AF7C2ED06A3E50225794DE9C5E92D1D3B04/\"\n },\n },\n [\"Curse of the Rougarou\"] = {\n {\n Name = \"Curse of the Rougarou 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725494513/DF8E92EA5C1131A0C5D8FA06BFF6FD239412E11C/\"\n },\n {\n Name = \"Curse of the Rougarou 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725494706/5D2EDE5D07DDA6E5781DB70D13F9A17EF26D36F2/\"\n },\n {\n Name = \"Curse of the Rougarou 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725494855/44A751CB66CBE4D75E67A53FC392696F6A3BFD4C/\"\n },\n {\n Name = \"Curse of the Rougarou 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725495011/ADD3431B383236BCF057C1573CEF7E43F39FDE72/\"\n },\n {\n Name = \"Curse of the Rougarou 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725495146/79159992D5002AD3D7D23ED82D9BB76D437B94C3/\"\n }\n },\n [\"Guardians of the Abyss\"] = {\n {\n Name = \"Guardians of the Abyss 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725490870/9C03B2974D7776B8E2AFEEF025756D1885AF0AE3/\"\n },\n {\n Name = \"Guardians of the Abyss 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725491039/E81F05AB9C802F57F4D9F7229CE3D53231ACB70D/\"\n },\n {\n Name = \"Guardians of the Abyss 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725491202/384AA7DBA614B61C46D57EF5105A96F25F938B74/\"\n },\n {\n Name = \"Guardians of the Abyss 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725491392/1C8FF752DF97F362BA8937BFEC65140AE3ADF8A6/\"\n },\n {\n Name = \"Guardians of the Abyss 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725491512/06B1DCA10B44FF86567CEFCC135D619648CE5F19/\"\n },\n {\n Name = \"Guardians of the Abyss 6\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725491658/5446E231AEF72CF4F7B4892116671FF7175EFA0F/\"\n }\n },\n [\"The Labyrinths of Lunacy\"] = {\n {\n Name = \"The Labyrinths of Lunacy 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725489685/D2D342844212C8A21E030418935A227C2E3279DB/\"\n },\n {\n Name = \"The Labyrinths of Lunacy 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725489820/E3E18B0940C2604F62E564AD43F178FF9F13B3C9/\"\n },\n {\n Name = \"The Labyrinths of Lunacy 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725489972/6A34CF53190EAAAF57C31FB97A3C2ACBD27FEE40/\"\n }\n },\n [\"Murder at the Excelsior Hotel\"] = {\n {\n Name = \"Murder at the Excelsior Hotel 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725488868/7F7FE8BB3C7E3645B4377F86366C6073CDB8F113/\"\n },\n {\n Name = \"Murder at the Excelsior Hotel 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725489144/53A920E2D1A9F41937B21B0A5B1A4E450ABFC460/\"\n }\n },\n [\"War of the Outer Gods\"] = {\n {\n Name = \"War of the Outer Gods\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725487627/43A19A6D97A6DA63A487EB247EE95884E2D9F5FD/\"\n }\n }\n },\n [\"Fan-Made Campaigns\"] = {\n [\"Cyclopean Foundations\"] = {\n {\n Name = \"I - Lost Moorings 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725499518/02DA17FC9D6A1174E484977269F44AE6995C6F7C/\"\n },\n {\n Name = \"I - Lost Moorings 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725499680/1556F230B59D42FCA47A5A87135330B03C231E92/\"\n },\n {\n Name = \"II - Going Twice\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725499855/1220C81273EFA6F36C2AEBA713E31DE1E2F92454/\"\n },\n {\n Name = \"III - Private Lives\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725500069/452E4427185A7F1AFB3F2CBB263DC55B6A144D49/\"\n },\n {\n Name = \"IV - Crumbling Masonry 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725500260/94FE8506AB13CA51F087ABF155799F73BCBAB1E9/\"\n },\n {\n Name = \"IV - Crumbling Masonry 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725500508/04B6C6D8845BF5411D28C79D185EAF6FFBB409F5/\"\n },\n {\n Name = \"V - Across Dreadful Waters\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725500640/447069BBBF70474439D3CC4F970F6617C8B738F4/\"\n },\n {\n Name = \"VI - Blood From Stones\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725500803/23C46C5F08E3F911F565D9EC38CFACFFAA5F5B11/\"\n },\n {\n Name = \"VII - Pyroclastic Flow 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725500952/804B531E517B1AD2294E304AA6F72F8CC3E6FC4E/\"\n },\n {\n Name = \"VII - Pyroclastic Flow 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725501115/E771289EB848A695DF47C405300B1EC7CA925009/\"\n },\n {\n Name = \"VIII - Tomb of Dead Dreams 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725501272/CAE6C4185540F3F8FFA2A8E37458A5B80DBD70FC/\"\n },\n {\n Name = \"VIII - Tomb of Dead Dreams 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725501415/DA9C07488DA2753FF5621D1731A84D6D0B1CC1BD/\"\n },\n {\n Name = \"VIII - Tomb of Dead Dreams 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725501813/030E5DB9F8F6C5F092EFDF2C42AD631318B0923A/\"\n }\n },\n [\"Dark Matter\"] = {\n {\n Name = \"I - The Tatterdemalion 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725504118/AC852F478D5BDA0C8A54A499B07A66E872560EC7/\"\n },\n {\n Name = \"I - The Tatterdemalion 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725504319/5B24BB2080AC76D836708AABC1BC90FD884F043D/\"\n },\n {\n Name = \"I - The Tatterdemalion 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725504461/73E4632A2EAAFA918924E60A64B03838CA6DDD77/\"\n },\n {\n Name = \"I - The Tatterdemalion 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725504602/6DB8F081CC907A0D6F364E5045BB7E8FADA91B5C/\"\n },\n {\n Name = \"II - Electric Nightmares 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725504770/C6FB5FDD153ACD07565259AE013FDC7FF567037D/\"\n },\n {\n Name = \"II - Electric Nightmares 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725504974/80E29EA68B88B78CDADC475998E832C7245409F4/\"\n },\n {\n Name = \"IIIa - Lost Quantum\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725505211/07E1254B1C601496E47B7E60B736D1699AAD38C8/\"\n },\n {\n Name = \"IIIb - In the Shadow of Earth 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725505419/7E8B50470AD6AD27429B58A42271755289FC90EB/\"\n },\n {\n Name = \"IIIb - In the Shadow of Earth 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725505603/DCD5B255FE66F8D8F47FB6C928D80583F3F950AC/\"\n },\n {\n Name = \"IIIc - Strange Moons\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725506071/78597C2FBE2DE55BFC86AEC9F42FE1B20D26544C/\"\n },\n {\n Name = \"IV - The Machine in Yellow\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725426327/41F6192EDCFFD6AAE2EE44C2BB5708B19D7464A9/\"\n },\n {\n Name = \"V - Fragment of Carcosa 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725506388/A299C8D58171A6D78CF55D911C2B81C63D88444F/\"\n },\n {\n Name = \"V - Fragment of Carcosa 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725506567/C36509CB6520803355E7AE1E9EC8CD35641B28C8/\"\n },\n {\n Name = \"VI - Starfall 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725506714/327D0E565039B7FA9157FDA04A302DF178C64C44/\"\n },\n {\n Name = \"VI - Starfall 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725506809/E637DAAD8BEB00E4305756D101E1E6B370CB1644/\"\n },\n {\n Name = \"VI - Starfall 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725506978/A17CD45A7770BAC7196218ADD2FB6CEB0E7A0E6B/\"\n }\n },\n [\"The Ghosts of Onigawa\"] = {\n {\n Name = \"I - The Hidden Village\",\n URL = \"https://i.imgur.com/btTQffc.jpeg\"\n },\n {\n Name = \"II - The House on the Hill\",\n URL = \"https://i.imgur.com/YTHt8JQ.jpeg\"\n },\n {\n Name = \"III - The River Delta\",\n URL = \"https://i.imgur.com/9Zk3iLJ.png\"\n },\n {\n Name = \"IV - The War Eternal\",\n URL = \"https://i.imgur.com/6UtFHhc.jpeg\"\n },\n {\n Name = \"V - Half Light\",\n URL = \"https://i.imgur.com/hul7lLL.png\"\n },\n {\n Name = \"VI - The End of August\",\n URL = \"https://i.imgur.com/PKWtpG7.jpeg\"\n },\n {\n Name = \"VII - The Molten Armory\",\n URL = \"https://i.imgur.com/kMSdBRh.jpeg\"\n },\n {\n Name = \"VIII - The Black Harvest\",\n URL = \"https://i.imgur.com/6ySucTS.jpeg\"\n }\n }\n },\n [\"Fan-Made Scenarios\"] = {\n [\"Side Scenarios (FM)\"] = {\n {\n Name = \"Code Red at Bleeding Heart\",\n URL = \"https://i.imgur.com/nTstdlj.jpeg\"\n },\n {\n Name = \"Consternation on the Constellation\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725512402/37F34A14CEEA9D2F889F7B97B065C0193F268FE1/\"\n },\n {\n Name = \"Symphony of Erich Zann\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725512613/B23EA91E9489E0DDE250DD33F9AF1A12EEE52E0C/\"\n }\n }\n },\n [\"Other Images\"] = {\n [\"Arkham Locations\"] = {\n {\n Name = \"Downtown 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725516086/53F48F8AA9CFE4BF544BF03A616AC12A5344615C/\"\n },\n {\n Name = \"Downtown 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725516316/1A337F5D66D7B5F59C66F465710717340B1D56AB/\"\n },\n {\n Name = \"Eastside 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725516542/09B4BE1E5487C3B11C0178B0B6FFD51620BE6AA6/\"\n },\n {\n Name = \"Eastside 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725516744/9B7F54E99D9B85884D5E363B97B25DA2DD3F03CC/\"\n },\n {\n Name = \"French Hill\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725516949/8BFEF09FDB6608173280F887C1BA3906427678CC/\"\n },\n {\n Name = \"Generic 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725517086/93E00AA823FBA1C6531BBA143408E1E7D89BE3F0/\"\n },\n {\n Name = \"Generic 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725517270/1450BCB6698058F833FAE770D31D0D064B82F5C2/\"\n },\n {\n Name = \"Generic 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725517434/5B529D9DEF3550E898744CE19AAD4CC0AB3F12DF/\"\n },\n {\n Name = \"Generic 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725517622/FE0C331881B776E66D3A2C60D70147A0CABFDAC6/\"\n },\n {\n Name = \"Generic 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725517833/A123F1A2D1B8BE960AAB371D9FD06F27C282CB9B/\"\n },\n {\n Name = \"Generic 6\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725518026/10D4F06C8A1AEC3ACAEC5C3B9DA142D3BA5818FE/\"\n },\n {\n Name = \"Generic 7\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725518144/72D4A60264C2DD201AAA5FFDCA95C6FF04EF8AC8/\"\n },\n {\n Name = \"Generic 8\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725518292/A1848A68389FBECA5BC847F90A921C18133B17D6/\"\n },\n {\n Name = \"Merchant District\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725518454/BD6694DCCD12E31997202B2020B4A29FDC96FC7B/\"\n },\n {\n Name = \"Miskatonic University\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725518846/79D6BEB0D8C274E3D308A67CD3181418B02D3A7E/\"\n },\n {\n Name = \"Northside\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725519012/E4B527768AFEFE0E4FB4518CA2AFDD69A98AB5D1/\"\n },\n {\n Name = \"Rivertown\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725519190/7A9A09861EECE2D98B5C1EB694E88C2073ABDFDF/\"\n },\n {\n Name = \"Southside\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725519353/FE43349A25231F48662309FEB331DB2C418A5E80/\"\n },\n {\n Name = \"Uptown\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725519551/3630457608AD2DB605EC4BCF4332C1D0983305C0/\"\n }\n },\n [\"Default Image\"] = {\n {\n Name = \"Default Image\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/998015670465071049/FFAE162920D67CF38045EFBD3B85AD0F916147B2/\"\n }\n },\n [\"Unsorted\"] = {\n {\n Name = \"Kingsport\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725522594/1EA2C0AF5D4D346AD3FFDC38215BB20AAA72CE8D/\"\n },\n {\n Name = \"Devil\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2115062479282248687/DD84A3CB3C4A475A5D093CB413A16A5CEA5FBF79/\"\n },\n {\n Name = \"Mystic Board\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2115062479282248488/EC27B1215F558A39954C27477D8B4F916CA211E5/\"\n }\n }\n }\n}\nend)\n__bundle_register(\"core/PlayAreaSelector\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/PlayAreaImageData\") -- this fills the variable \"PLAYAREA_IMAGE_DATA\"\nlocal optionPanelApi = require(\"core/OptionPanelApi\")\nlocal playAreaApi = require(\"core/PlayAreaApi\")\nlocal typeIndex, selectionIndex, plainNameCache\n\nfunction onSave() return JSON.encode({ typeIndex = typeIndex, selectionIndex = selectionIndex }) end\n\nfunction onLoad(savedData)\n self.createButton({\n function_owner = self,\n click_function = \"onClick_toggleGallery\",\n tooltip = \"Show Image Gallery\",\n position = {0, 0.06, 0},\n height = 1500,\n width = 1500,\n color = { 1, 1, 1, 0 }\n })\n\n local loadedData = JSON.decode(savedData) or {}\n typeIndex = loadedData.typeIndex or 1\n selectionIndex = loadedData.selectionIndex or 1\n Wait.time(updatePlayAreaGallery, 0.5)\n math.randomseed(os.time())\nend\n\n-- click function for main button\nfunction onClick_toggleGallery(_, playerColor)\n Global.call(\"togglePlayAreaGallery\", playerColor)\nend\n\nfunction getDataSubTableByIndex(dataTable, index)\n local loopId = 1\n for i, v in pairs(dataTable) do\n if index == loopId then return v end\n loopId = loopId + 1\n end\n return {}\nend\n\nfunction updatePlayAreaGallery()\n -- get subtables\n local dataForType = getDataSubTableByIndex(PLAYAREA_IMAGE_DATA, typeIndex)\n local dataForSelection = getDataSubTableByIndex(dataForType, selectionIndex)\n\n -- get global xml to insert elements\n local globalXml = UI.getXmlTable()\n\n -- selectable items\n local itemSelection = getXmlTableElementById(globalXml, 'itemSelection')\n itemSelection.children = {}\n\n local i = 0\n for itemName, _ in pairs(dataForType) do\n i = i + 1\n table.insert(itemSelection.children,\n {\n tag = \"Panel\",\n attributes = { class = \"itemPanel\", id = \"typePanel\" .. i },\n children = {\n tag = \"Text\",\n value = itemName,\n attributes = { class = \"itemText\", id = \"typeListText\" .. i }\n }\n })\n end\n\n -- selectable images for that item\n local playareaList = getXmlTableElementById(globalXml, 'playareaList')\n playareaList.children = {}\n\n for i, v in ipairs(dataForSelection) do\n table.insert(playareaList.children,\n {\n tag = \"VerticalLayout\",\n attributes = { class = \"imageBox\", id = \"image\" .. i },\n children = {\n {\n tag = 'Image',\n attributes = { class = \"playareaImage\", image = v.URL }\n },\n {\n tag = 'Text',\n value = v.Name,\n attributes = { class = \"imageName\" }\n }\n }\n })\n end\n\n playareaList.attributes.height = round(#playareaList.children / 2, 0) * 380\n Global.call(\"updateGlobalXml\", globalXml)\n Wait.time(highlightTabAndItem, 0.1)\nend\n\nfunction onClick_imageTab(_, _, tabId)\n typeIndex = tonumber(tabId:sub(9))\n selectionIndex = 1\n updatePlayAreaGallery()\nend\n\nfunction onClick_listItem(_, _, listId)\n selectionIndex = tonumber(listId:sub(10))\n updatePlayAreaGallery()\nend\n\nfunction onClick_image(player, _, id)\n local imageIndex = tonumber(id:sub(6))\n local dataForType = getDataSubTableByIndex(PLAYAREA_IMAGE_DATA, typeIndex)\n local dataForSelection = getDataSubTableByIndex(dataForType, selectionIndex)\n local newURL = dataForSelection[imageIndex].URL\n playAreaApi.updateSurface(newURL)\n Global.call(\"togglePlayAreaGallery\", player.color)\nend\n\nfunction highlightTabAndItem()\n -- highlight active tab\n for i = 1, 5 do\n local color = \"#888888\"\n if i == typeIndex then color = \"#ffffff\" end\n UI.setAttribute(\"imageTab\" .. i, \"color\", color)\n end\n\n -- highlight item\n UI.setAttribute(\"typePanel\" .. selectionIndex, \"color\", \"grey\")\n UI.setAttribute(\"typeListText\" .. selectionIndex, \"color\", \"black\")\nend\n\n-- loops through an XML table and returns the specified object\n---@param ui table XmlTable (get this via getXmlTable)\n---@param id string Id of the object to return\nfunction getXmlTableElementById(ui, id)\n for _, obj in ipairs(ui) do\n if obj.attributes and obj.attributes.id and obj.attributes.id == id then return obj end\n if obj.children then\n local result = getXmlTableElementById(obj.children, id)\n if result then return result end\n end\n end\n return nil\nend\n\n-- utility function\nfunction round(num, numDecimalPlaces)\n local mult = 10 ^ (numDecimalPlaces or 0)\n return math.floor(num * mult + 0.5) / mult\nend\n\nfunction maybeUpdatePlayAreaImage(scenarioName)\n -- check if option is enabled\n local optionPanelState = optionPanelApi.getOptions()\n if not optionPanelState[\"changePlayAreaImage\"] then return end\n\n -- initialize cache if nil\n if not plainNameCache then\n plainNameCache = {}\n for i, dataForType in pairs(PLAYAREA_IMAGE_DATA) do\n for j, dataForCycle in pairs(dataForType) do\n for k, data in ipairs(dataForCycle) do\n local plainName = getPlainName(data.Name)\n \n -- override plainName for all images in the \"Other Images\" category (except the default image)\n if i == \"Other Images\" and data.Name ~= \"Default Image\" then\n plainName = \"Generic\"\n end\n\n if not plainNameCache[plainName] then\n plainNameCache[plainName] = {}\n end\n table.insert(plainNameCache[plainName], data.URL)\n end\n end\n end\n end\n\n -- look for matching playarea image or use generic ones instead\n local listOfEligibleImages = {}\n if plainNameCache[scenarioName] then\n listOfEligibleImages = plainNameCache[scenarioName]\n else\n listOfEligibleImages = plainNameCache[\"Generic\"]\n end\n\n -- get a random entry from the eligible list\n local newImageIndex = math.random(#listOfEligibleImages)\n playAreaApi.updateSurface(listOfEligibleImages[newImageIndex])\nend\n\n-- attempts to extract the plain scenario name from the playarea image name\nfunction getPlainName(str)\n -- remove prefix type 1\n str = str:gsub(\"%w+%-%w%s%-%s\", \"\") -- matches \"II-B - Thousand Shapes of Horror 1\"\n \n -- remove prefix type 2\n str = str:gsub(\"%w+%-%w%s\", \"\") -- matches \"59-Z Congress of Keys 1\"\n\n -- remove prefix type 3\n str = str:gsub(\"%w+%s%-%s\", \"\") -- matches \"III - The Secret Name 4\"\n\n -- remove prefix type 4\n str = str:gsub(\"%?+%s%-%s\", \"\") -- matches \"??? - Fatal Mirage\"\n\n -- remove suffix (numbering)\n str = str:gsub(\"%s%d+\", \"\")\n\n return str\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/PlayAreaSelector\")\nend)\n__bundle_register(\"core/PlayAreaSelector\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/PlayAreaImageData\") -- this fills the variable \"PLAYAREA_IMAGE_DATA\"\nlocal optionPanelApi = require(\"core/OptionPanelApi\")\nlocal playAreaApi = require(\"core/PlayAreaApi\")\nlocal typeIndex, selectionIndex, plainNameCache\n\nfunction onSave() return JSON.encode({ typeIndex = typeIndex, selectionIndex = selectionIndex }) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData) or {}\n typeIndex = loadedData.typeIndex or 1\n selectionIndex = loadedData.selectionIndex or 1\n end\n\n self.createButton({\n function_owner = self,\n click_function = \"onClick_toggleGallery\",\n tooltip = \"Show Image Gallery\",\n position = {0, 0.06, 0},\n height = 1500,\n width = 1500,\n color = { 1, 1, 1, 0 }\n })\n\n Wait.time(updatePlayAreaGallery, 0.5)\n math.randomseed(os.time())\nend\n\n-- click function for main button\nfunction onClick_toggleGallery(_, playerColor)\n Global.call(\"togglePlayAreaGallery\", playerColor)\nend\n\nfunction getDataSubTableByIndex(dataTable, index)\n local loopId = 1\n for i, v in pairs(dataTable) do\n if index == loopId then return v end\n loopId = loopId + 1\n end\n return {}\nend\n\nfunction updatePlayAreaGallery()\n -- get subtables\n local dataForType = getDataSubTableByIndex(PLAYAREA_IMAGE_DATA, typeIndex)\n local dataForSelection = getDataSubTableByIndex(dataForType, selectionIndex)\n\n -- get global xml to insert elements\n local globalXml = UI.getXmlTable()\n\n -- selectable items\n local itemSelection = getXmlTableElementById(globalXml, 'itemSelection')\n itemSelection.children = {}\n\n local i = 0\n for itemName, _ in pairs(dataForType) do\n i = i + 1\n table.insert(itemSelection.children,\n {\n tag = \"Panel\",\n attributes = { class = \"itemPanel\", id = \"typePanel\" .. i },\n children = {\n tag = \"Text\",\n value = itemName,\n attributes = { class = \"itemText\", id = \"typeListText\" .. i }\n }\n })\n end\n\n -- selectable images for that item\n local playareaList = getXmlTableElementById(globalXml, 'playareaList')\n playareaList.children = {}\n\n for i, v in ipairs(dataForSelection) do\n table.insert(playareaList.children,\n {\n tag = \"VerticalLayout\",\n attributes = { class = \"imageBox\", id = \"image\" .. i },\n children = {\n {\n tag = 'Image',\n attributes = { class = \"playareaImage\", image = v.URL }\n },\n {\n tag = 'Text',\n value = v.Name,\n attributes = { class = \"imageName\" }\n }\n }\n })\n end\n\n playareaList.attributes.height = round(#playareaList.children / 2, 0) * 380\n Global.call(\"updateGlobalXml\", globalXml)\n Wait.time(highlightTabAndItem, 0.1)\nend\n\nfunction onClick_imageTab(_, _, tabId)\n typeIndex = tonumber(tabId:sub(9))\n selectionIndex = 1\n updatePlayAreaGallery()\nend\n\nfunction onClick_listItem(_, _, listId)\n selectionIndex = tonumber(listId:sub(10))\n updatePlayAreaGallery()\nend\n\nfunction onClick_image(player, _, id)\n local imageIndex = tonumber(id:sub(6))\n local dataForType = getDataSubTableByIndex(PLAYAREA_IMAGE_DATA, typeIndex)\n local dataForSelection = getDataSubTableByIndex(dataForType, selectionIndex)\n local newURL = dataForSelection[imageIndex].URL\n playAreaApi.updateSurface(newURL)\n Global.call(\"togglePlayAreaGallery\", player.color)\nend\n\nfunction highlightTabAndItem()\n -- highlight active tab\n for i = 1, 5 do\n local color = \"#888888\"\n if i == typeIndex then color = \"#ffffff\" end\n UI.setAttribute(\"imageTab\" .. i, \"color\", color)\n end\n\n -- highlight item\n UI.setAttribute(\"typePanel\" .. selectionIndex, \"color\", \"grey\")\n UI.setAttribute(\"typeListText\" .. selectionIndex, \"color\", \"black\")\nend\n\n-- loops through an XML table and returns the specified object\n---@param ui table XmlTable (get this via getXmlTable)\n---@param id string Id of the object to return\nfunction getXmlTableElementById(ui, id)\n for _, obj in ipairs(ui) do\n if obj.attributes and obj.attributes.id and obj.attributes.id == id then return obj end\n if obj.children then\n local result = getXmlTableElementById(obj.children, id)\n if result then return result end\n end\n end\n return nil\nend\n\n-- utility function\nfunction round(num, numDecimalPlaces)\n local mult = 10 ^ (numDecimalPlaces or 0)\n return math.floor(num * mult + 0.5) / mult\nend\n\nfunction maybeUpdatePlayAreaImage(scenarioName)\n -- check if option is enabled\n local optionPanelState = optionPanelApi.getOptions()\n if not optionPanelState[\"changePlayAreaImage\"] then return end\n\n -- initialize cache if nil\n if not plainNameCache then\n plainNameCache = {}\n for i, dataForType in pairs(PLAYAREA_IMAGE_DATA) do\n for j, dataForCycle in pairs(dataForType) do\n for k, data in ipairs(dataForCycle) do\n local plainName = getPlainName(data.Name)\n \n -- override plainName for all images in the \"Other Images\" category (except the default image)\n if i == \"Other Images\" and data.Name ~= \"Default Image\" then\n plainName = \"Generic\"\n end\n\n if not plainNameCache[plainName] then\n plainNameCache[plainName] = {}\n end\n table.insert(plainNameCache[plainName], data.URL)\n end\n end\n end\n end\n\n -- look for matching playarea image or use generic ones instead\n local listOfEligibleImages = {}\n if plainNameCache[scenarioName] then\n listOfEligibleImages = plainNameCache[scenarioName]\n else\n listOfEligibleImages = plainNameCache[\"Generic\"]\n end\n\n -- get a random entry from the eligible list\n local newImageIndex = math.random(#listOfEligibleImages)\n playAreaApi.updateSurface(listOfEligibleImages[newImageIndex])\nend\n\n-- attempts to extract the plain scenario name from the playarea image name\nfunction getPlainName(str)\n -- remove prefix type 1\n str = str:gsub(\"%w+%-%w%s%-%s\", \"\") -- matches \"II-B - Thousand Shapes of Horror 1\"\n \n -- remove prefix type 2\n str = str:gsub(\"%w+%-%w%s\", \"\") -- matches \"59-Z Congress of Keys 1\"\n\n -- remove prefix type 3\n str = str:gsub(\"%w+%s%-%s\", \"\") -- matches \"III - The Secret Name 4\"\n\n -- remove prefix type 4\n str = str:gsub(\"%?+%s%-%s\", \"\") -- matches \"??? - Fatal Mirage\"\n\n -- remove suffix (numbering)\n str = str:gsub(\"%s%d+\", \"\")\n\n return str\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/PlayAreaImageData\", function(require, _LOADED, __bundle_register, __bundle_modules)\nPLAYAREA_IMAGE_DATA = {\n [\"Official Campaigns\"] = {\n [\"Night of the Zealot\"] = {\n {\n Name = \"I - The Gathering 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725443007/D34B55D2637EF1DF22839D12F9CF74F92F8EB486/\"\n },\n {\n Name = \"III - The Devourer Below 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725443203/FBE04C8B89F79D18C6D29C28DC3B292A5A3A3DEB/\"\n },\n {\n Name = \"III - The Devourer Below 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725443345/FD10BC04B3F3AFD710C3C12EE14F85F9AFB265E6/\"\n }\n },\n [\"The Dunwich Legacy\"] = {\n {\n Name = \"I-A - Extracurricular Activity 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725401398/AC55F0754B7E4A39796A6F2236012AE03DA55E20/\"\n },\n {\n Name = \"I-A - Extracurricular Activity 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725401658/9F3ED6E256818C4528D55980B9D7E44B87170A4F/\"\n },\n {\n Name = \"I-A - Extracurricular Activity 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725401870/FE29404D9D93BE2735D41C115DDD9708A0931F3E/\"\n },\n {\n Name = \"I-B - The House Always Wins 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725402059/4C4A50D259ECFD4DFB94FABB9FA2AD3AABDCA0CA/\"\n },\n {\n Name = \"I-B - The House Always Wins 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725402263/8B0C981B78E803B3BFD64AC874F315B6810E579B/\"\n },\n {\n Name = \"I-B - The House Always Wins 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725402460/8599D17306C644D75D189591BC6D57C2F27F9E35/\"\n },\n {\n Name = \"I-B - The House Always Wins 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725402641/777865B25BCF86C2EFEAE232AFBC31561D12AE0F/\"\n },\n {\n Name = \"II - The Miskatonic Museum 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725402804/A44E68AC08E6568A757429B29E71C703B76FA159/\"\n },\n {\n Name = \"II - The Miskatonic Museum 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725403000/B28D46D5B7BCE9EA9BF27D3A0A932393D8258A76/\"\n },\n {\n Name = \"III - The Essex County Express\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725403150/956BE4B5C25805E57C8FC5CF28A94BD7EF07CA54/\"\n },\n {\n Name = \"IV - Blood on the Altar 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725403290/07DD1508BA880AD1212A820BC29471C48DC90C53/\"\n },\n {\n Name = \"IV - Blood on the Altar 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725403456/A74398E8CCD78657C2555832A3B340723E8C9117/\"\n },\n {\n Name = \"IV - Blood on the Altar 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725403636/CD89D7D9CC020F41D5AD02D54E308877583EC45F/\"\n },\n {\n Name = \"IV - Blood on the Altar 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725403818/AEFAC50DAC82271BCACC53B8FF69B5B094FA1078/\"\n },\n {\n Name = \"V - Undimensioned and Unseen 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725403955/E7C566E536CF6E910DB654FC1DBF4838F2BAF899/\"\n },\n {\n Name = \"V - Undimensioned and Unseen 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725404127/F92F123BBD3D857C579B9284988C3AFFBCD84B2B/\"\n },\n {\n Name = \"V - Undimensioned and Unseen 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725404273/7F8CFE6785BD74BB8D5E34C204AFB8AA580CA3E3/\"\n },\n {\n Name = \"V - Undimensioned and Unseen 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725404424/C2AE08371CF2DE2777791BBD4AEF446E50532382/\"\n },\n {\n Name = \"VI - Where Doom Awaits 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725404578/A520CE0F6B0C8591A48ADEF34E68B46AFC2BC83B/\"\n },\n {\n Name = \"VI - Where Doom Awaits 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725404740/1FF9EF375BDBB73CA8F0A1562F215692AAEA7131/\"\n },\n {\n Name = \"VI - Where Doom Awaits 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725404914/5473D20CE0122F55EEADB16C4353D4EDD91E440E/\"\n },\n {\n Name = \"VI - Where Doom Awaits 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725405088/A0AA8CB864747152763D434D0737D81EB515E71B/\"\n },\n {\n Name = \"VI - Where Doom Awaits 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725405247/FAF408DAAD4FC72142DFDFE5FCEA4B84293AA72C/\"\n },\n {\n Name = \"VII - Lost in Time and Space 1\",\n URL = \"https://i.ibb.co/rtTpbDx/Dunwich-8-Lost-in-Time-amp-Space.jpg\"\n },\n {\n Name = \"VII - Lost in Time and Space 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725405746/771BAE40F98BB16F8D011FA794E4AC0095131AF1/\"\n },\n {\n Name = \"VII - Lost in Time and Space 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725406148/D15D56EA34F27C651D7E7AC202DA4DEBE395E310/\"\n }\n },\n [\"The Path to Carcosa\"] = {\n {\n Name = \"I - Curtain Call\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725426327/41F6192EDCFFD6AAE2EE44C2BB5708B19D7464A9/\"\n },\n {\n Name = \"II - The Last King 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725426499/114EAEA245AC51CA219364AF26341E7F7E649A7D/\"\n },\n {\n Name = \"II - The Last King 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725426683/A2762E95DD79D7A7BC749925166BBFC18B62EF3B/\"\n },\n {\n Name = \"II - The Last King 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725426818/A6A20773EA95CE3D9896B22E317A0E1ACCA911F0/\"\n },\n {\n Name = \"III - Echoes of the Past\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725427005/25F51DE4B1F33C16A0E68C929E5002F0C4520A37/\"\n },\n {\n Name = \"IV - The Unspeakable Oath 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725427178/9575E4F6E53DDAD2D3E61684AB9757B04E1EF787/\"\n },\n {\n Name = \"IV - The Unspeakable Oath 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725427342/199A6C6411992ACFB8A417E86207FE6CE956EB97/\"\n },\n {\n Name = \"IV - The Unspeakable Oath 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725427501/48525BCDFA281947FA9ED26507BC1F81C07056E8/\"\n },\n {\n Name = \"V - A Phantom of Truth 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725427681/F72B02FF1A5E58CBCB0E53C8455310AF37064477/\"\n },\n {\n Name = \"V - A Phantom of Truth 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725427848/215A757FF28317EB3EF7CF1F9CAE6F1CFF735091/\"\n },\n {\n Name = \"VI - The Pallid Mask 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725428067/D46BAD80B112156A2D3DEFF247A74C74F27DDA12/\"\n },\n {\n Name = \"VI - The Pallid Mask 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725428250/464681CF59770BFD493A0D672C7CB70BA8CD3499/\"\n },\n {\n Name = \"VII - Black Stars Rise 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725428431/4766E1A4893E0EF16B576749B73CE449F10DA20C/\"\n },\n {\n Name = \"VII - Black Stars Rise 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725428896/05ED3D08F29C8E6EC080F0615DE130F2A687A9AC/\"\n },\n {\n Name = \"VIII - Dim Carcosa 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725429052/BA81DBDE7A12B993CB8B7001CA93095AD0512449/\"\n },\n {\n Name = \"VIII - Dim Carcosa 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725429235/C5C939E0213575B5EDCA6723D209892071DDE4B5/\"\n }\n },\n [\"The Forgotten Age\"] = {\n {\n Name = \"I - The Untamed Wilds 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725446729/7F5E48BC9A028AE5117231364F2D5B433A62239A/\"\n },\n {\n Name = \"I - The Untamed Wilds 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725446946/55C374DC5BE3620CB0D5BCA379EA55CF471D09B3/\"\n },\n {\n Name = \"I - The Untamed Wilds 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725447172/6EAE2CFD3AC552CFB744C75E4E26A79264DE17D3/\"\n },\n {\n Name = \"I - The Untamed Wilds 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725447409/FCF48C94D90F94FBFFD674B0650E288E7312C441/\"\n },\n {\n Name = \"I - The Untamed Wilds 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725447579/F7C3FB9E31147430C1384684887FC66E616D0302/\"\n },\n {\n Name = \"II - The Doom of Eztli 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725447752/44EF68E1BF3C2D9DCD5306DD90B4CCCFBE03891C/\"\n },\n {\n Name = \"II - The Doom of Eztli 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725448027/F5F14EC590C33BC87D8F0CFF43D7E4DF80D61133/\"\n },\n {\n Name = \"II - The Doom of Eztli 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725448215/BFD9D940DB8EC9AC8D818C48BBAE3338A8E48A3B/\"\n },\n {\n Name = \"III - Threads of Fate\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725448393/67F3BE7DC1BEC807A17D3F8914328D408856E019/\"\n },\n {\n Name = \"IV - The Boundary Beyond 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725448568/3C268415A47430CEEC3F9BFB216EF57E3DBF820A/\"\n },\n {\n Name = \"IV - The Boundary Beyond 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725448701/3FA23DCA30505AD4C27D8914740AD3138C01122C/\"\n },\n {\n Name = \"IV - The Boundary Beyond 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725448863/266C3320AC326C30F08FBC11A95567E1249E7FB7/\"\n },\n {\n Name = \"V - Heart of the Elders 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725449019/A6CC459ACA004C33DD9605BE8382437F6BBE24F7/\"\n },\n {\n Name = \"V - Heart of the Elders 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725449150/241FA88572B6B4F652D7FC6D1EDB23DF94E3199C/\"\n },\n {\n Name = \"V - Heart of the Elders 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725449310/DBD731498FAB399A4155F7B64F8710BF5FBB5C1F/\"\n },\n {\n Name = \"VI - The City of Archives 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725449473/527CB6470F508D4E1F1E4AFC8A0D3AB0A65E046E/\"\n },\n {\n Name = \"VI - The City of Archives 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725449630/A8E933F79A646990155CC18A2143B3BC16222750/\"\n },\n {\n Name = \"VI - The City of Archives 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725449814/30BB7E4F8D9F1571A420372E78ACAF2D7792811F/\"\n },\n {\n Name = \"VII - The Depths of Yoth 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725449962/D69532827DFF2D654F8A606B7917D593F52D7624/\"\n },\n {\n Name = \"VII - The Depths of Yoth 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725450085/479A8A1BDD7BE80B43AE4F2C14DFA811D7B28482/\"\n },\n {\n Name = \"VII - The Depths of Yoth 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725450258/E617F5A78DFBE913652E20BF97D38B91087FACAE/\"\n },\n {\n Name = \"VIII - Shattered Aeons 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725450415/5631152D4830C00DB8D8EB2163CE773542A62C79/\"\n },\n {\n Name = \"VIII - Shattered Aeons 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725450556/C3000D020B0C32B4DA3420AEE5E286893453FC49/\"\n }\n },\n [\"The Circle Undone\"] = {\n {\n Name = \"0 - Disappearance at the Twilight Estate\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725457506/6E228F87CEDCD3A0CFA28B680C266B4C68C7682B/\"\n },\n {\n Name = \"I - The Witching Hour\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725457706/D0FDC0E9287C343745AE6135352194D654D98B64/\"\n },\n {\n Name = \"II - At Death's Doorstep 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725457864/3106851EC93B1FC01311BD68F02145BA2FD720B0/\"\n },\n {\n Name = \"II - At Death's Doorstep 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725458037/155EB572CF28F09A64A021CAC3A3219C31B2CD49/\"\n },\n {\n Name = \"II - At Death's Doorstep 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725458187/482CC6730F267061A055D6FD402603BC642A9635/\"\n },\n {\n Name = \"III - The Secret Name 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725458373/769D67103FACFB94E77465E85DBB2A250284B59B/\"\n },\n {\n Name = \"III - The Secret Name 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725458592/D70CE9B1AD7158AF206A25777A8BA6F284587A83/\"\n },\n {\n Name = \"III - The Secret Name 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725458848/2FC0D5AFFA97AB5E80244F1ED711036B2149B0EE/\"\n },\n {\n Name = \"III - The Secret Name 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459026/A1A5B18ECB38985A35781CBDFF53935541720AF4/\"\n },\n {\n Name = \"IV - The Wages of Sin 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459182/46870E1DBE623E93E675CB2D3C1E959B40CDCC83/\"\n },\n {\n Name = \"IV - The Wages of Sin 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459344/9552699A8CEC5E7BF22843990394BB977539CBE0/\"\n },\n {\n Name = \"IV - The Wages of Sin 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459466/9B6B55A6F76668929B6D6B1DD5FDAE7CEE427A1C/\"\n },\n {\n Name = \"IV - The Wages of Sin 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459609/054A60BDCD266C1A53F29067CFC83D0561666FE4/\"\n },\n {\n Name = \"IV - Wages of Sin 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459714/11B3D734AC5229A0DEA5372CD50F5C7841F9D5A0/\"\n },\n {\n Name = \"V - For the Greater Good 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459829/9AA9563CCD72A8593BDE3C6D1299E96325ECE747/\"\n },\n {\n Name = \"V - For the Greater Good 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725459933/13A103B7BC0ABB611F6A8E61D033C6AD95EED4D4/\"\n },\n {\n Name = \"V - For the Greater Good 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725460088/C88DDC5CE898ACEF360B8AD72E05F15BF84DE171/\"\n },\n {\n Name = \"V - For the Greater Good 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725460182/C086EDA78636624FC9C4EA1DBCD8F1D39B7A6A89/\"\n },\n {\n Name = \"VI - Union and Disillusion\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725460382/8EFB842A623A2D1E6D0E915268A207A5D7DFC6D4/\"\n },\n {\n Name = \"VII - In the Clutches of Chaos 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725460586/7E156BF93F211BC425CD37ED273FCC84FF1F4C4D/\"\n },\n {\n Name = \"VII - In the Clutches of Chaos 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725460740/72A39A0FACA806EF2E0A4E31AEDF6D8FCDF1A876/\"\n },\n {\n Name = \"VII - In the Clutches of Chaos 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725460884/5716F6E2CB3F8D14FA5B7B806555896088696057/\"\n },\n {\n Name = \"VIII - Before the Black Throne 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725461042/DFF7A992A9440E58CE32D4B8A96A02A8F785AC90/\"\n },\n {\n Name = \"VIII - Before the Black Throne 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725461161/18902B2F74C9D70F5EA79A34521E3FDEDEFC893D/\"\n }\n },\n [\"The Dream-Eaters\"] = {\n {\n Name = \"I-A - Beyond the Gates of Sleep 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725465733/828EE1FF16928EA0426BC68AAED4B9AA6B6FBB49/\"\n },\n {\n Name = \"I-A - Beyond the Gates of Sleep 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725465934/35A85E9056B7A212AC39E7043FDF546A425E62F2/\"\n },\n {\n Name = \"I-A - Beyond the Gates of Sleep 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725466105/05D29313D2559B6683465A7034DE7B07DE675420/\"\n },\n {\n Name = \"I-B - Waking Nightmare\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725466267/16FAE20612ED0A6A65836DD1B014AC5A801A172F/\"\n },\n {\n Name = \"II-A - The Search for Kadath 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725466425/03CCD5F24999CC6CC905CB2FD021DB67D7769163/\"\n },\n {\n Name = \"II-A - The Search for Kadath 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725466615/085ACE95FEF03D2BE91BAD5E1864E1D0263DCCC0/\"\n },\n {\n Name = \"II-A - The Search for Kadath 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725466802/83861733568FCA9673B6F5EFE0C9D3337E3DFD27/\"\n },\n {\n Name = \"II-A - The Search for Kadath 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725466941/D4FDE1FE722DC6B03AD38D797F2E00531908583D/\"\n },\n {\n Name = \"II-A - The Search for Kadath 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725467396/C9A476395B9326142BBDBD06D22A14C83EAD2161/\"\n },\n {\n Name = \"II-B - A Thousand Shapes of Horror 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725467582/5EB69F3A3F20B312FE3FE3C64FEA96200EE51563/\"\n },\n {\n Name = \"II-B - A Thousand Shapes of Horror 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725467791/5FE437C821641EDD703D336205A37F8F0CACFD38/\"\n },\n {\n Name = \"II-B - A Thousand Shapes of Horror 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725467946/841CEC1D8B56C1CA52B5558E8E49CE04D95D2F4A/\"\n },\n {\n Name = \"III-A - Dark Side of the Moon 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725468100/2DD1038163AD5DAA759EA4BE49DB82A2718E931F/\"\n },\n {\n Name = \"III-A - Dark Side of the Moon 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725468293/E8145D05833864EEC70AF9AC401039D8E8AFDE3E/\"\n },\n {\n Name = \"III-B - Point of No Return 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725468506/1F2E3D425A4D97ADBCA59B4A9401C411F91F875F/\"\n },\n {\n Name = \"III-B - Point of No Return 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725468694/8631E68BA7CE69BECF1D476A03CBDC79112A60BF/\"\n },\n {\n Name = \"IV-A - Where the Gods Dwell\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725468880/2C8A9459149D33E526FDC4B68A063475305C15F8/\"\n },\n {\n Name = \"IV-B - Weaver of the Cosmos 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725469060/9E6AF9E0D68EC0F44B82968CE99E433A25A0E0C4/\"\n },\n {\n Name = \"IV-B - Weaver of the Cosmos 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725469224/8C969B8ABAEE6CFFEF165C2E4BBA0E7E9B33AA1A/\"\n },\n {\n Name = \"IV-B - Weaver of the Cosmos 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725469417/A94C14A64836FB9B5FAFAC5B790C51441F8D475F/\"\n }\n },\n [\"The Innsmouth Conspiracy\"] = {\n {\n Name = \"I - The Pit of Despair 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725473070/57FEAA8135F62DBAD52E2AAB562EF45EB9A0194A/\"\n },\n {\n Name = \"I - The Pit of Despair 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725473257/FEC6F9FAA1CC656BFD5861F58E4751BC94AB0424/\"\n },\n {\n Name = \"II - The Vanishing of Elina Harper 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725473424/B0E2BFA9C7F61A5B7A72CD11AD1AFF4A070AFFA1/\"\n },\n {\n Name = \"II - The Vanishing of Elina Harper 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725473570/D28C2DA099D656116A0D7BAA8B874E4ED6B6B50E/\"\n },\n {\n Name = \"II - The Vanishing of Elina Harper 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725473731/EE9BED3522A1B7CD5E394A67AD7F692DB709A9B5/\"\n },\n {\n Name = \"II - The Vanishing of Elina Harper 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725473874/0A85B2CE9A3FFB048C932E1B014B2986D5D42A1B/\"\n },\n {\n Name = \"II - Vanishing of Elina Harper 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725474056/C82E467216DF747AA954C614D7D0B8F649163EDA/\"\n },\n {\n Name = \"III - In Too Deep 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725474234/C6A72CDEFCDF1F2A3C6036F349B5F368EFDACA2E/\"\n },\n {\n Name = \"III - In Too Deep 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725474398/752D0CE313C58A5B1C3181503C841EB91D041492/\"\n },\n {\n Name = \"III - In Too Deep 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725474562/308687DFB9B0F2286A9248698FD38C0BF66B89ED/\"\n },\n {\n Name = \"IV - Devil Reef 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725474717/DCEC44D2F7F22A950B3CF52C81C8F931710EFADC/\"\n },\n {\n Name = \"IV - Devil Reef 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725474883/04913E71194BF766DFF2DF8646251AC461A35FE2/\"\n },\n {\n Name = \"V - Horror in High Gear 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725475029/FAA34C92FA800E8DDF6449B1C48FCC7468D783BD/\"\n },\n {\n Name = \"V - Horror in High Gear 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725475133/BC689B58040F74E7DB44CFD8F3F2BF32FE4081E1/\"\n },\n {\n Name = \"V - Horror in High Gear 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725475307/53ADF5E957F88F1DDCE46828547E5808C3CAEFD7/\"\n },\n {\n Name = \"V - Horror in High Gear 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725475402/C41EB1D2F8549669DD4323A339F5EC594996816C/\"\n },\n {\n Name = \"VI - A Light in the Fog 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725475509/C526C9A3AC34195ACF6161D4821D1424A8A288B4/\"\n },\n {\n Name = \"VI - A Light in the Fog 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725475660/2C67D57967F300BD1FE1AFC08C49EBCF4A88D11C/\"\n },\n {\n Name = \"VII - The Lair of Dagon 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725476055/4BC221648012F7A7A37B2F65929705E973FF9CE3/\"\n },\n {\n Name = \"VII - The Lair of Dagon 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725476271/3F9CF0FE8ACCE12E26ACA5D5777177A10B49D6DA/\"\n },\n {\n Name = \"VIII - Into the Maelstrom 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725476474/AF8695342FBCE6F6BC7B353C86C6006F1629F43A/\"\n },\n {\n Name = \"VIII - Into the Maelstrom 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725476643/CB175401ECDF04F97334CBF8AE7EC76A43A85735/\"\n }\n },\n [\"Edge of the Earth\"] = {\n {\n Name = \"I - Ice and Death 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725482152/322E07021DC78455859C860D8B1574F1BA2E0F68/\"\n },\n {\n Name = \"I - Ice and Death 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725482327/BD14DDE856A2062A939F860743FFF15F8B0BFF5A/\"\n },\n {\n Name = \"I - Ice and Death 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725482520/0FB5AC83DF448994EC0A866ACF6AF57ADCC59C82/\"\n },\n {\n Name = \"??? - Fatal Mirage\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725481929/A35EDF11BD6AF52784BA6611C363CBBB373622EE/\"\n },\n {\n Name = \"II - To the Forbidden Peaks 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725482688/B50455616DFC14FE0B9398DBE2A3A1AE25040516/\"\n },\n {\n Name = \"II - To the Forbidden Peaks 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725482839/17786225AA56E75E558491E7E710F555AF3E5799/\"\n },\n {\n Name = \"III - City of the Elder Things 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725483014/B74378E02A1A99F544CD98141EF62193A2A612FB/\"\n },\n {\n Name = \"III - City of the Elder Things 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725483208/CDFF7A2D404485DE2B4C4ED54B34E197515F0094/\"\n },\n {\n Name = \"IV - The Heart of Madness 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725483349/A96BC4AA73C71FE86EF38110236BAEF710C00EE2/\"\n },\n {\n Name = \"IV - The Heart of Madness 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725483528/5BF0DD740C5D43EFBFEF0436EB35FF9DA748FA5E/\"\n }\n },\n [\"The Scarlet Keys\"] = {\n {\n Name = \"5-A Riddles and Rain\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2037357792057358580/E9E5FE4028C08B3D4883406821221B73C8B5B2C7/\"\n },\n {\n Name = \"11-B Dead Heat\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2038485431566443853/CAD7771D90141EA6D5FFAFE1EC5E7AD9647C82DB/\"\n },\n {\n Name = \"16-D Sanguine Shadows\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2037357792057358704/4A7261EB31511467CBC46E876476DD205F528A4B/\"\n },\n {\n Name = \"21-F Dealings in the Dark\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2037357792057358816/7C9FE4C34CD0A7AE87EF054742D878F310C71AA7/\"\n },\n {\n Name = \"28-I Dancing Mad\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2037357792056955518/EAB857DD5629EC6A3078FB0A3A703B85B5F514B9/\"\n },\n {\n Name = \"23-K On Thin Ice\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2038485431566444026/EB5628E254AE25DA89A9C999EAAD995ECF67068E/\"\n },\n {\n Name = \"38-N Dogs of War\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2038485431566444199/194FD9A713907197471A55411AE300B62C5F5278/\"\n },\n {\n Name = \"46-Q Shades of Suffering\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2038485431566444330/3ED2CCE95DE933546E1B5CBBF445D773E6D65465/\"\n },\n {\n Name = \"56-Y Without a Trace\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2038485431566444450/FE4C335B0F72E83900A4EED0FD1A1D304D70D6B7/\"\n },\n {\n Name = \"59-Z Congress of the Keys 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2038485431566444576/5BB32469ED412D59BB0A46E57D226500B1D0568B/\"\n },\n {\n Name = \"59-Z Congress of the Keys 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2038485431566444690/B01A1FEAB57473D9B6DF11B92D62C214AA1C2C02/\"\n }\n }\n },\n [\"Official Scenarios\"] = {\n [\"The Blob That Ate Everything\"] = {\n {\n Name = \"The Blob That Ate Everything 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725489144/53A920E2D1A9F41937B21B0A5B1A4E450ABFC460/\"\n },\n {\n Name = \"The Blob That Ate Everything 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725488396/9CC07F923BD1CBFC4BB06DD2CC6747D2C3541737/\"\n }\n },\n [\"Carnevale of Horrors\"] = {\n {\n Name = \"Carnevale of Horrors 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725496678/91164AF7C2ED06A3E50225794DE9C5E92D1D3B04/\"\n },\n },\n [\"Curse of the Rougarou\"] = {\n {\n Name = \"Curse of the Rougarou 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725494513/DF8E92EA5C1131A0C5D8FA06BFF6FD239412E11C/\"\n },\n {\n Name = \"Curse of the Rougarou 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725494706/5D2EDE5D07DDA6E5781DB70D13F9A17EF26D36F2/\"\n },\n {\n Name = \"Curse of the Rougarou 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725494855/44A751CB66CBE4D75E67A53FC392696F6A3BFD4C/\"\n },\n {\n Name = \"Curse of the Rougarou 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725495011/ADD3431B383236BCF057C1573CEF7E43F39FDE72/\"\n },\n {\n Name = \"Curse of the Rougarou 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725495146/79159992D5002AD3D7D23ED82D9BB76D437B94C3/\"\n }\n },\n [\"Guardians of the Abyss\"] = {\n {\n Name = \"Guardians of the Abyss 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725490870/9C03B2974D7776B8E2AFEEF025756D1885AF0AE3/\"\n },\n {\n Name = \"Guardians of the Abyss 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725491039/E81F05AB9C802F57F4D9F7229CE3D53231ACB70D/\"\n },\n {\n Name = \"Guardians of the Abyss 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725491202/384AA7DBA614B61C46D57EF5105A96F25F938B74/\"\n },\n {\n Name = \"Guardians of the Abyss 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725491392/1C8FF752DF97F362BA8937BFEC65140AE3ADF8A6/\"\n },\n {\n Name = \"Guardians of the Abyss 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725491512/06B1DCA10B44FF86567CEFCC135D619648CE5F19/\"\n },\n {\n Name = \"Guardians of the Abyss 6\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725491658/5446E231AEF72CF4F7B4892116671FF7175EFA0F/\"\n }\n },\n [\"The Labyrinths of Lunacy\"] = {\n {\n Name = \"The Labyrinths of Lunacy 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725489685/D2D342844212C8A21E030418935A227C2E3279DB/\"\n },\n {\n Name = \"The Labyrinths of Lunacy 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725489820/E3E18B0940C2604F62E564AD43F178FF9F13B3C9/\"\n },\n {\n Name = \"The Labyrinths of Lunacy 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725489972/6A34CF53190EAAAF57C31FB97A3C2ACBD27FEE40/\"\n }\n },\n [\"Murder at the Excelsior Hotel\"] = {\n {\n Name = \"Murder at the Excelsior Hotel 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725488868/7F7FE8BB3C7E3645B4377F86366C6073CDB8F113/\"\n },\n {\n Name = \"Murder at the Excelsior Hotel 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725489144/53A920E2D1A9F41937B21B0A5B1A4E450ABFC460/\"\n }\n },\n [\"War of the Outer Gods\"] = {\n {\n Name = \"War of the Outer Gods\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725487627/43A19A6D97A6DA63A487EB247EE95884E2D9F5FD/\"\n }\n }\n },\n [\"Fan-Made Campaigns\"] = {\n [\"Cyclopean Foundations\"] = {\n {\n Name = \"I - Lost Moorings 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725499518/02DA17FC9D6A1174E484977269F44AE6995C6F7C/\"\n },\n {\n Name = \"I - Lost Moorings 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725499680/1556F230B59D42FCA47A5A87135330B03C231E92/\"\n },\n {\n Name = \"II - Going Twice\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725499855/1220C81273EFA6F36C2AEBA713E31DE1E2F92454/\"\n },\n {\n Name = \"III - Private Lives\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725500069/452E4427185A7F1AFB3F2CBB263DC55B6A144D49/\"\n },\n {\n Name = \"IV - Crumbling Masonry 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725500260/94FE8506AB13CA51F087ABF155799F73BCBAB1E9/\"\n },\n {\n Name = \"IV - Crumbling Masonry 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725500508/04B6C6D8845BF5411D28C79D185EAF6FFBB409F5/\"\n },\n {\n Name = \"V - Across Dreadful Waters\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725500640/447069BBBF70474439D3CC4F970F6617C8B738F4/\"\n },\n {\n Name = \"VI - Blood From Stones\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725500803/23C46C5F08E3F911F565D9EC38CFACFFAA5F5B11/\"\n },\n {\n Name = \"VII - Pyroclastic Flow 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725500952/804B531E517B1AD2294E304AA6F72F8CC3E6FC4E/\"\n },\n {\n Name = \"VII - Pyroclastic Flow 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725501115/E771289EB848A695DF47C405300B1EC7CA925009/\"\n },\n {\n Name = \"VIII - Tomb of Dead Dreams 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725501272/CAE6C4185540F3F8FFA2A8E37458A5B80DBD70FC/\"\n },\n {\n Name = \"VIII - Tomb of Dead Dreams 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725501415/DA9C07488DA2753FF5621D1731A84D6D0B1CC1BD/\"\n },\n {\n Name = \"VIII - Tomb of Dead Dreams 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725501813/030E5DB9F8F6C5F092EFDF2C42AD631318B0923A/\"\n }\n },\n [\"Dark Matter\"] = {\n {\n Name = \"I - The Tatterdemalion 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725504118/AC852F478D5BDA0C8A54A499B07A66E872560EC7/\"\n },\n {\n Name = \"I - The Tatterdemalion 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725504319/5B24BB2080AC76D836708AABC1BC90FD884F043D/\"\n },\n {\n Name = \"I - The Tatterdemalion 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725504461/73E4632A2EAAFA918924E60A64B03838CA6DDD77/\"\n },\n {\n Name = \"I - The Tatterdemalion 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725504602/6DB8F081CC907A0D6F364E5045BB7E8FADA91B5C/\"\n },\n {\n Name = \"II - Electric Nightmares 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725504770/C6FB5FDD153ACD07565259AE013FDC7FF567037D/\"\n },\n {\n Name = \"II - Electric Nightmares 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725504974/80E29EA68B88B78CDADC475998E832C7245409F4/\"\n },\n {\n Name = \"IIIa - Lost Quantum\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725505211/07E1254B1C601496E47B7E60B736D1699AAD38C8/\"\n },\n {\n Name = \"IIIb - In the Shadow of Earth 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725505419/7E8B50470AD6AD27429B58A42271755289FC90EB/\"\n },\n {\n Name = \"IIIb - In the Shadow of Earth 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725505603/DCD5B255FE66F8D8F47FB6C928D80583F3F950AC/\"\n },\n {\n Name = \"IIIc - Strange Moons\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725506071/78597C2FBE2DE55BFC86AEC9F42FE1B20D26544C/\"\n },\n {\n Name = \"IV - The Machine in Yellow\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725426327/41F6192EDCFFD6AAE2EE44C2BB5708B19D7464A9/\"\n },\n {\n Name = \"V - Fragment of Carcosa 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725506388/A299C8D58171A6D78CF55D911C2B81C63D88444F/\"\n },\n {\n Name = \"V - Fragment of Carcosa 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725506567/C36509CB6520803355E7AE1E9EC8CD35641B28C8/\"\n },\n {\n Name = \"VI - Starfall 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725506714/327D0E565039B7FA9157FDA04A302DF178C64C44/\"\n },\n {\n Name = \"VI - Starfall 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725506809/E637DAAD8BEB00E4305756D101E1E6B370CB1644/\"\n },\n {\n Name = \"VI - Starfall 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725506978/A17CD45A7770BAC7196218ADD2FB6CEB0E7A0E6B/\"\n }\n },\n [\"The Ghosts of Onigawa\"] = {\n {\n Name = \"I - The Hidden Village\",\n URL = \"https://i.imgur.com/btTQffc.jpeg\"\n },\n {\n Name = \"II - The House on the Hill\",\n URL = \"https://i.imgur.com/YTHt8JQ.jpeg\"\n },\n {\n Name = \"III - The River Delta\",\n URL = \"https://i.imgur.com/9Zk3iLJ.png\"\n },\n {\n Name = \"IV - The War Eternal\",\n URL = \"https://i.imgur.com/6UtFHhc.jpeg\"\n },\n {\n Name = \"V - Half Light\",\n URL = \"https://i.imgur.com/hul7lLL.png\"\n },\n {\n Name = \"VI - The End of August\",\n URL = \"https://i.imgur.com/PKWtpG7.jpeg\"\n },\n {\n Name = \"VII - The Molten Armory\",\n URL = \"https://i.imgur.com/kMSdBRh.jpeg\"\n },\n {\n Name = \"VIII - The Black Harvest\",\n URL = \"https://i.imgur.com/6ySucTS.jpeg\"\n }\n }\n },\n [\"Fan-Made Scenarios\"] = {\n [\"Side Scenarios (FM)\"] = {\n {\n Name = \"Code Red at Bleeding Heart\",\n URL = \"https://i.imgur.com/nTstdlj.jpeg\"\n },\n {\n Name = \"Consternation on the Constellation\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725512402/37F34A14CEEA9D2F889F7B97B065C0193F268FE1/\"\n },\n {\n Name = \"Symphony of Erich Zann\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725512613/B23EA91E9489E0DDE250DD33F9AF1A12EEE52E0C/\"\n }\n }\n },\n [\"Other Images\"] = {\n [\"Arkham Locations\"] = {\n {\n Name = \"Downtown 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725516086/53F48F8AA9CFE4BF544BF03A616AC12A5344615C/\"\n },\n {\n Name = \"Downtown 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725516316/1A337F5D66D7B5F59C66F465710717340B1D56AB/\"\n },\n {\n Name = \"Eastside 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725516542/09B4BE1E5487C3B11C0178B0B6FFD51620BE6AA6/\"\n },\n {\n Name = \"Eastside 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725516744/9B7F54E99D9B85884D5E363B97B25DA2DD3F03CC/\"\n },\n {\n Name = \"French Hill\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725516949/8BFEF09FDB6608173280F887C1BA3906427678CC/\"\n },\n {\n Name = \"Generic 1\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725517086/93E00AA823FBA1C6531BBA143408E1E7D89BE3F0/\"\n },\n {\n Name = \"Generic 2\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725517270/1450BCB6698058F833FAE770D31D0D064B82F5C2/\"\n },\n {\n Name = \"Generic 3\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725517434/5B529D9DEF3550E898744CE19AAD4CC0AB3F12DF/\"\n },\n {\n Name = \"Generic 4\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725517622/FE0C331881B776E66D3A2C60D70147A0CABFDAC6/\"\n },\n {\n Name = \"Generic 5\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725517833/A123F1A2D1B8BE960AAB371D9FD06F27C282CB9B/\"\n },\n {\n Name = \"Generic 6\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725518026/10D4F06C8A1AEC3ACAEC5C3B9DA142D3BA5818FE/\"\n },\n {\n Name = \"Generic 7\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725518144/72D4A60264C2DD201AAA5FFDCA95C6FF04EF8AC8/\"\n },\n {\n Name = \"Generic 8\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725518292/A1848A68389FBECA5BC847F90A921C18133B17D6/\"\n },\n {\n Name = \"Merchant District\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725518454/BD6694DCCD12E31997202B2020B4A29FDC96FC7B/\"\n },\n {\n Name = \"Miskatonic University\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725518846/79D6BEB0D8C274E3D308A67CD3181418B02D3A7E/\"\n },\n {\n Name = \"Northside\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725519012/E4B527768AFEFE0E4FB4518CA2AFDD69A98AB5D1/\"\n },\n {\n Name = \"Rivertown\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725519190/7A9A09861EECE2D98B5C1EB694E88C2073ABDFDF/\"\n },\n {\n Name = \"Southside\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725519353/FE43349A25231F48662309FEB331DB2C418A5E80/\"\n },\n {\n Name = \"Uptown\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725519551/3630457608AD2DB605EC4BCF4332C1D0983305C0/\"\n }\n },\n [\"Default Image\"] = {\n {\n Name = \"Default Image\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/998015670465071049/FFAE162920D67CF38045EFBD3B85AD0F916147B2/\"\n }\n },\n [\"Unsorted\"] = {\n {\n Name = \"Kingsport\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2279446315725522594/1EA2C0AF5D4D346AD3FFDC38215BB20AAA72CE8D/\"\n },\n {\n Name = \"Devil\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2115062479282248687/DD84A3CB3C4A475A5D093CB413A16A5CEA5FBF79/\"\n },\n {\n Name = \"Mystic Board\",\n URL = \"http://cloud-3.steamusercontent.com/ugc/2115062479282248488/EC27B1215F558A39954C27477D8B4F916CA211E5/\"\n }\n }\n }\n}\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "{\"selectionIndex\":1,\"typeIndex\":1}", "MeasureMovement": false, "Name": "Custom_Token", @@ -88996,6 +89006,314 @@ "Value": 0, "XmlUI": "" }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "CardID": 14000, + "ColorDiffuse": { + "b": 0.71324, + "g": 0.71324, + "r": 0.71324 + }, + "CustomDeck": { + "140": { + "BackIsHidden": true, + "BackURL": "http://cloud-3.steamusercontent.com/ugc/2414565357243141810/67954474A3DC9311DA0628A864960FD14DD1C7D0/", + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2414565357243141984/62A87E727E9F6120771487CC69B71224623A018F/", + "NumHeight": 1, + "NumWidth": 1, + "Type": 0, + "UniqueBack": false + } + }, + "Description": "The Reporter", + "DragSelectable": true, + "GMNotes": "{\n \"id\": \"02002-p\",\n \"type\": \"Investigator\",\n \"class\": \"Seeker\",\n \"traits\": \"Reporter.\",\n \"willpowerIcons\": 3,\n \"intellectIcons\": 4,\n \"combatIcons\": 2,\n \"agilityIcons\": 3,\n \"cycle\": \"Hunting for Answers\"\n}", + "GUID": "0a5492", + "Grid": true, + "GridProjection": false, + "Hands": true, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "CardCustom", + "Nickname": "Rex Murphy (Parallel)", + "SidewaysCard": true, + "Snap": true, + "Sticky": true, + "Tags": [ + "Investigator", + "PlayerCard" + ], + "Tooltip": true, + "Transform": { + "posX": 53.274, + "posY": 3.137, + "posZ": 22.081, + "rotX": 0, + "rotY": 180, + "rotZ": 0, + "scaleX": 1.15, + "scaleY": 1, + "scaleZ": 1.15 + }, + "Value": 0, + "XmlUI": "" + }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "CardID": 14100, + "ColorDiffuse": { + "b": 0.71324, + "g": 0.71324, + "r": 0.71324 + }, + "CustomDeck": { + "141": { + "BackIsHidden": true, + "BackURL": "http://cloud-3.steamusercontent.com/ugc/2414565357243141810/67954474A3DC9311DA0628A864960FD14DD1C7D0/", + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2414565357243142219/EB53C43AB498B112B5EA2C488F0EB1543CD43DE5/", + "NumHeight": 1, + "NumWidth": 1, + "Type": 0, + "UniqueBack": false + } + }, + "Description": "The Reporter", + "DragSelectable": true, + "GMNotes": "{\n \"id\": \"02002-pb\",\n \"type\": \"Investigator\",\n \"class\": \"Seeker\",\n \"traits\": \"Reporter.\",\n \"willpowerIcons\": 3,\n \"intellectIcons\": 4,\n \"combatIcons\": 2,\n \"agilityIcons\": 3,\n \"cycle\": \"Hunting for Answers\"\n}", + "GUID": "0a5493", + "Grid": true, + "GridProjection": false, + "Hands": true, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "CardCustom", + "Nickname": "Rex Murphy (Parallel Back)", + "SidewaysCard": true, + "Snap": true, + "Sticky": true, + "Tags": [ + "Investigator", + "PlayerCard" + ], + "Tooltip": true, + "Transform": { + "posX": 53.274, + "posY": 3.137, + "posZ": 22.081, + "rotX": 0, + "rotY": 180, + "rotZ": 0, + "scaleX": 1.15, + "scaleY": 1, + "scaleZ": 1.15 + }, + "Value": 0, + "XmlUI": "" + }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "CardID": 14200, + "ColorDiffuse": { + "b": 0.71324, + "g": 0.71324, + "r": 0.71324 + }, + "CustomDeck": { + "142": { + "BackIsHidden": true, + "BackURL": "http://cloud-3.steamusercontent.com/ugc/2414565357243142126/51E7BDBC4F3E68487E896E867200B6C9310ADF3D/", + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2414565357243141984/62A87E727E9F6120771487CC69B71224623A018F/", + "NumHeight": 1, + "NumWidth": 1, + "Type": 0, + "UniqueBack": false + } + }, + "Description": "The Reporter", + "DragSelectable": true, + "GMNotes": "{\n \"id\": \"02002-pf\",\n \"type\": \"Investigator\",\n \"class\": \"Seeker\",\n \"traits\": \"Reporter.\",\n \"willpowerIcons\": 3,\n \"intellectIcons\": 4,\n \"combatIcons\": 2,\n \"agilityIcons\": 3,\n \"cycle\": \"Hunting for Answers\"\n}", + "GUID": "0a5494", + "Grid": true, + "GridProjection": false, + "Hands": true, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "CardCustom", + "Nickname": "Rex Murphy (Parallel Front)", + "SidewaysCard": true, + "Snap": true, + "Sticky": true, + "Tags": [ + "Investigator", + "PlayerCard" + ], + "Tooltip": true, + "Transform": { + "posX": 53.274, + "posY": 3.137, + "posZ": 22.081, + "rotX": 0, + "rotY": 180, + "rotZ": 0, + "scaleX": 1.15, + "scaleY": 1, + "scaleZ": 1.15 + }, + "Value": 0, + "XmlUI": "" + }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "CardID": 14400, + "ColorDiffuse": { + "b": 0.71324, + "g": 0.71324, + "r": 0.71324 + }, + "CustomDeck": { + "144": { + "BackIsHidden": true, + "BackURL": "http://cloud-3.steamusercontent.com/ugc/2342503777940352139/A2D42E7E5C43D045D72CE5CFC907E4F886C8C690/", + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2414565357243142330/B4BB77B904CF3AFAF3181392C4849174F3D87D46/", + "NumHeight": 1, + "NumWidth": 1, + "Type": 0, + "UniqueBack": false + } + }, + "Description": "Advanced", + "DragSelectable": true, + "GMNotes": "{\n \"id\": \"90079\",\n \"type\": \"Event\",\n \"class\": \"Neutral\",\n \"cost\": 1,\n \"traits\": \"Insight.\",\n \"intellectIcons\": 2,\n \"wildIcons\": 1,\n \"cycle\": \"Hunting for Answers\"\n}", + "GUID": "4156dd", + "Grid": true, + "GridProjection": false, + "Hands": true, + "HideWhenFaceDown": true, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "CardCustom", + "Nickname": "Search for the Truth", + "SidewaysCard": false, + "Snap": true, + "Sticky": true, + "Tags": [ + "PlayerCard" + ], + "Tooltip": true, + "Transform": { + "posX": 9.099, + "posY": 3.726, + "posZ": -16.715, + "rotX": 0, + "rotY": 270, + "rotZ": 0, + "scaleX": 1, + "scaleY": 1, + "scaleZ": 1 + }, + "Value": 0, + "XmlUI": "" + }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "CardID": 14500, + "ColorDiffuse": { + "b": 0.71324, + "g": 0.71324, + "r": 0.71324 + }, + "CustomDeck": { + "145": { + "BackIsHidden": true, + "BackURL": "http://cloud-3.steamusercontent.com/ugc/2342503777940352139/A2D42E7E5C43D045D72CE5CFC907E4F886C8C690/", + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2414565357243142499/838D53FA16318A3141B6F5875B11F6B87FA7C37F/", + "NumHeight": 1, + "NumWidth": 1, + "Type": 0, + "UniqueBack": false + } + }, + "Description": "Advanced", + "DragSelectable": true, + "GMNotes": "{\n \"id\": \"90080\",\n \"type\": \"Treachery\",\n \"class\": \"Neutral\",\n \"traits\": \"Curse.\",\n \"weakness\": true,\n \"cycle\": \"Hunting for Answers\"\n}", + "GUID": "033a36", + "Grid": true, + "GridProjection": false, + "Hands": true, + "HideWhenFaceDown": true, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Card", + "Nickname": "Rex's Curse", + "SidewaysCard": false, + "Snap": true, + "Sticky": true, + "Tags": [ + "PlayerCard" + ], + "Tooltip": true, + "Transform": { + "posX": 9.132, + "posY": 5.515, + "posZ": -16.723, + "rotX": 0, + "rotY": 270, + "rotZ": 0, + "scaleX": 1, + "scaleY": 1, + "scaleZ": 1 + }, + "Value": 0, + "XmlUI": "" + }, { "AltLookAngle": { "x": 0, @@ -89542,7 +89860,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/BookofLivingMyths\")\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/cards/BookofLivingMyths\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nfunction onLoad(savedData)\n self.addContextMenuItem(\"Enable Helper\", createButtons)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.loopId then\n createButtons()\n end\n end\nend\n\nfunction deleteButtons()\n self.clearContextMenu()\n self.addContextMenuItem(\"Enable Helper\", createButtons)\n self.UI.setAttribute(\"inactives\", \"active\", false)\n self.UI.setAttribute(\"actives\", \"active\", false)\n if loopId then Wait.stop(loopId) end\n loopId = nil\n self.script_state = JSON.encode({ loopId = loopId })\nend\n\n-- create buttons and begin monitoring chaos bag for curse and bless tokens\nfunction createButtons()\n self.clearContextMenu()\n self.addContextMenuItem(\"Clear Helper\", deleteButtons)\n self.UI.setAttribute(\"inactives\", \"active\", true)\n self.UI.setAttribute(\"actives\", \"active\", true)\n loopId = Wait.time(maybeUpdateButtonState, 1, -1)\n self.script_state = JSON.encode({ loopId = loopId })\nend\n\nfunction resolveToken(player, _, tokenType)\n local matColor\n if player.color == \"Black\" then\n matColor = playmatApi.getMatColorByPosition(self.getPosition())\n else\n matColor = playmatApi.getMatColor(player.color)\n end\n\n local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\")\n chaosBagApi.drawChaosToken(mat, true, tokenType)\nend\n\n-- count tokens in the bag and show appropriate buttons\nfunction maybeUpdateButtonState()\n local numInBag = getBlessCurseInBag()\n local state = { Bless = false, Curse = false }\n\n if numInBag.Bless \u003e= numInBag.Curse and numInBag.Bless \u003e 0 then\n state.Bless = true\n end\n\n if numInBag.Curse \u003e= numInBag.Bless and numInBag.Curse \u003e 0 then\n state.Curse = true\n end\n\n setUiState(state)\nend\n\nfunction getBlessCurseInBag()\n local numInBag = { Bless = 0, Curse = 0 }\n local chaosBag = chaosBagApi.findChaosBag()\n\n for _, v in ipairs(chaosBag.getObjects()) do\n if v.name == \"Bless\" then\n numInBag.Bless = numInBag.Bless + 1\n elseif v.name == \"Curse\" then\n numInBag.Curse = numInBag.Curse + 1\n end\n end\n\n return numInBag\nend\n\nfunction setUiState(params)\n -- set bless state\n if params.Bless then\n self.UI.show(\"Bless\")\n self.UI.hide(\"inactiveBless\")\n else\n self.UI.show(\"inactiveBless\")\n self.UI.hide(\"Bless\")\n end\n\n -- set curse state\n if params.Curse then\n self.UI.show(\"Curse\")\n self.UI.hide(\"inactiveCurse\")\n else\n self.UI.show(\"inactiveCurse\")\n self.UI.hide(\"Curse\")\n end\nend\n\nfunction errorMessage()\n local numInBag = getBlessCurseInBag()\n\n if numInBag.Bless == 0 and numInBag.Curse == 0 then\n broadcastToAll(\"There are no Bless or Curse tokens in the chaos bag.\", \"Red\")\n elseif numInBag.Bless \u003e numInBag.Curse then\n broadcastToAll(\"There are more Bless tokens than Curse tokens in the chaos bag.\", \"Red\")\n else\n broadcastToAll(\"There are more Curse tokens than Bless tokens in the chaos bag.\", \"Red\")\n end\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/BookofLivingMyths\")\nend)\n__bundle_register(\"playercards/cards/BookofLivingMyths\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nfunction onLoad(savedData)\n self.addContextMenuItem(\"Enable Helper\", createButtons)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.loopId then\n createButtons()\n end\n end\nend\n\nfunction deleteButtons()\n self.clearContextMenu()\n self.addContextMenuItem(\"Enable Helper\", createButtons)\n self.UI.setAttribute(\"inactives\", \"active\", false)\n self.UI.setAttribute(\"actives\", \"active\", false)\n if loopId then Wait.stop(loopId) end\n loopId = nil\n self.script_state = JSON.encode({ loopId = loopId })\nend\n\n-- create buttons and begin monitoring chaos bag for curse and bless tokens\nfunction createButtons()\n self.clearContextMenu()\n self.addContextMenuItem(\"Clear Helper\", deleteButtons)\n self.UI.setAttribute(\"inactives\", \"active\", true)\n self.UI.setAttribute(\"actives\", \"active\", true)\n loopId = Wait.time(maybeUpdateButtonState, 1, -1)\n self.script_state = JSON.encode({ loopId = loopId })\nend\n\nfunction resolveToken(player, _, tokenType)\n local matColor\n if player.color == \"Black\" then\n matColor = playmatApi.getMatColorByPosition(self.getPosition())\n else\n matColor = playmatApi.getMatColor(player.color)\n end\n\n local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\")\n chaosBagApi.drawChaosToken(mat, true, tokenType)\nend\n\n-- count tokens in the bag and show appropriate buttons\nfunction maybeUpdateButtonState()\n local numInBag = getBlessCurseInBag()\n local state = { Bless = false, Curse = false }\n\n if numInBag.Bless \u003e= numInBag.Curse and numInBag.Bless \u003e 0 then\n state.Bless = true\n end\n\n if numInBag.Curse \u003e= numInBag.Bless and numInBag.Curse \u003e 0 then\n state.Curse = true\n end\n\n setUiState(state)\nend\n\nfunction getBlessCurseInBag()\n local numInBag = { Bless = 0, Curse = 0 }\n local chaosBag = chaosBagApi.findChaosBag()\n\n for _, v in ipairs(chaosBag.getObjects()) do\n if v.name == \"Bless\" then\n numInBag.Bless = numInBag.Bless + 1\n elseif v.name == \"Curse\" then\n numInBag.Curse = numInBag.Curse + 1\n end\n end\n\n return numInBag\nend\n\nfunction setUiState(params)\n -- set bless state\n if params.Bless then\n self.UI.show(\"Bless\")\n self.UI.hide(\"inactiveBless\")\n else\n self.UI.show(\"inactiveBless\")\n self.UI.hide(\"Bless\")\n end\n\n -- set curse state\n if params.Curse then\n self.UI.show(\"Curse\")\n self.UI.hide(\"inactiveCurse\")\n else\n self.UI.show(\"inactiveCurse\")\n self.UI.hide(\"Curse\")\n end\nend\n\nfunction errorMessage()\n local numInBag = getBlessCurseInBag()\n\n if numInBag.Bless == 0 and numInBag.Curse == 0 then\n broadcastToAll(\"There are no Bless or Curse tokens in the chaos bag.\", \"Red\")\n elseif numInBag.Bless \u003e numInBag.Curse then\n broadcastToAll(\"There are more Bless tokens than Curse tokens in the chaos bag.\", \"Red\")\n else\n broadcastToAll(\"There are more Curse tokens than Bless tokens in the chaos bag.\", \"Red\")\n end\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -90269,7 +90587,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"10005\",\n \"type\": \"Asset\",\n \"class\": \"Neutral\",\n \"startsInPlay\": true,\n \"traits\": \"Item. Tool. Science.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"10006\"\n },\n {\n \"count\": 1,\n \"id\": \"10007\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GMNotes": "{\n \"id\": \"10005\",\n \"type\": \"Asset\",\n \"class\": \"Neutral\",\n \"startsInPlay\": true,\n \"traits\": \"Item. Tool. Science.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10006\"\n },\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10007\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", "GUID": "55990a", "Grid": true, "GridProjection": false, @@ -92924,7 +93242,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/FluteoftheOuterGods4\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/FluteoftheOuterGods4\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Curse\"] = true\n}\n\nSHOW_SINGLE_RELEASE = true\nKEEP_OPEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/FluteoftheOuterGods4\")\nend)\n__bundle_register(\"playercards/cards/FluteoftheOuterGods4\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Curse\"] = true\n}\n\nSHOW_SINGLE_RELEASE = true\nKEEP_OPEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -93294,7 +93612,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ShardsoftheVoid3\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/ShardsoftheVoid3\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"0\"] = true\n}\n\nSHOW_SINGLE_RELEASE = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ShardsoftheVoid3\")\nend)\n__bundle_register(\"playercards/cards/ShardsoftheVoid3\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"0\"] = true\n}\n\nSHOW_SINGLE_RELEASE = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -93602,7 +93920,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ScrollofSecrets\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat\n ---@param mat tts__Object Playermat that triggered this\n ---@param alwaysFaceUp boolean Whether the card should be drawn face-up\n MythosAreaApi.drawEncounterCard = function(mat, alwaysFaceUp)\n getMythosArea().call(\"drawEncounterCard\", {mat = mat, alwaysFaceUp = alwaysFaceUp})\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"playercards/cards/ScrollofSecrets\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between the lvl 0 and lvl 3 versions of Scroll of Secrets\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- get class via metadata and create context menu accordingly\nfunction onLoad()\n local notes = JSON.decode(self.getGMNotes())\n if notes then\n createContextMenu(notes.id)\n else\n print(\"Missing metadata for Scroll of Secrets!\")\n end\nend\n\nfunction createContextMenu(id)\n if id == \"05116\" or id == \"05116-t\" then\n -- lvl 0: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n elseif id == \"05188\" or id == \"05188-t\" then\n -- seeker lvl 3: draw 3 cards from the bottom\n self.addContextMenuItem(\"Draw bottom card(s)\", function(playerColor) contextFunc(playerColor, 3) end)\n elseif id == \"05189\" or id == \"05189-t\" then\n -- mystic lvl 3: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n end\nend\n\nfunction contextFunc(playerColor, amount)\n local options = { \"Encounter Deck\" }\n\n -- check for players with a deck and only display them as option\n for _, color in ipairs(Player.getAvailableColors()) do\n local matColor = playmatApi.getMatColor(color)\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n\n if deckAreaObjects.draw or deckAreaObjects.topCard then\n table.insert(options, color)\n end\n end\n\n -- show the target selection dialog\n Player[playerColor].showOptionsDialog(\"Select target deck\", options, _, function(owner) drawCardsFromBottom(playerColor, owner, amount) end)\nend\n\nfunction drawCardsFromBottom(playerColor, owner, amount)\n -- variable initialization\n local deck = nil\n local deckSize = 1\n local deckAreaObjects = {}\n\n -- get the respective deck\n if owner == \"Encounter Deck\" then\n deck = mythosAreaApi.getEncounterDeck()\n else\n local matColor = playmatApi.getMatColor(owner)\n deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n deck = deckAreaObjects.draw\n end\n\n -- error handling\n if not deck then\n printToColor(\"Couldn't find deck!\", playerColor)\n return\n end\n\n -- set deck size if there is actually a deck and not just a card\n if deck.type == \"Deck\" then\n deckSize = #deck.getObjects()\n end\n\n -- proceed according to deck size\n if deckSize \u003e amount then\n for i = 1, amount do\n local card = deck.takeObject({ top = false, flip = true })\n card.deal(1, playerColor)\n end\n else\n -- deal the whole deck\n deck.deal(amount, playerColor)\n\n if deckSize \u003c amount then\n -- Norman Withers handling\n if deckAreaObjects.topCard then\n deckAreaObjects.topCard.deal(1, playerColor)\n deckSize = deckSize + 1\n end\n\n -- warning message for player\n if deckSize \u003c amount then\n printToColor(\"Deck didn't contain enough cards.\", playerColor)\n end\n end\n end\n printToColor(\"Handle the drawn cards according to the ability text on 'Scroll of Secrets'.\", playerColor)\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ScrollofSecrets\")\nend)\n__bundle_register(\"playercards/cards/ScrollofSecrets\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between the lvl 0 and lvl 3 versions of Scroll of Secrets\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- get class via metadata and create context menu accordingly\nfunction onLoad()\n local notes = JSON.decode(self.getGMNotes())\n if notes then\n createContextMenu(notes.id)\n else\n print(\"Missing metadata for Scroll of Secrets!\")\n end\nend\n\nfunction createContextMenu(id)\n if id == \"05116\" or id == \"05116-t\" then\n -- lvl 0: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n elseif id == \"05188\" or id == \"05188-t\" then\n -- seeker lvl 3: draw 3 cards from the bottom\n self.addContextMenuItem(\"Draw bottom card(s)\", function(playerColor) contextFunc(playerColor, 3) end)\n elseif id == \"05189\" or id == \"05189-t\" then\n -- mystic lvl 3: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n end\nend\n\nfunction contextFunc(playerColor, amount)\n local options = { \"Encounter Deck\" }\n\n -- check for players with a deck and only display them as option\n for _, color in ipairs(Player.getAvailableColors()) do\n local matColor = playmatApi.getMatColor(color)\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n\n if deckAreaObjects.draw or deckAreaObjects.topCard then\n table.insert(options, color)\n end\n end\n\n -- show the target selection dialog\n Player[playerColor].showOptionsDialog(\"Select target deck\", options, _, function(owner) drawCardsFromBottom(playerColor, owner, amount) end)\nend\n\nfunction drawCardsFromBottom(playerColor, owner, amount)\n -- variable initialization\n local deck = nil\n local deckSize = 1\n local deckAreaObjects = {}\n\n -- get the respective deck\n if owner == \"Encounter Deck\" then\n deck = mythosAreaApi.getEncounterDeck()\n else\n local matColor = playmatApi.getMatColor(owner)\n deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n deck = deckAreaObjects.draw\n end\n\n -- error handling\n if not deck then\n printToColor(\"Couldn't find deck!\", playerColor)\n return\n end\n\n -- set deck size if there is actually a deck and not just a card\n if deck.type == \"Deck\" then\n deckSize = #deck.getObjects()\n end\n\n -- proceed according to deck size\n if deckSize \u003e amount then\n for i = 1, amount do\n local card = deck.takeObject({ top = false, flip = true })\n card.deal(1, playerColor)\n end\n else\n -- deal the whole deck\n deck.deal(amount, playerColor)\n\n if deckSize \u003c amount then\n -- Norman Withers handling\n if deckAreaObjects.topCard then\n deckAreaObjects.topCard.deal(1, playerColor)\n deckSize = deckSize + 1\n end\n\n -- warning message for player\n if deckSize \u003c amount then\n printToColor(\"Deck didn't contain enough cards.\", playerColor)\n end\n end\n end\n printToColor(\"Handle the drawn cards according to the ability text on 'Scroll of Secrets'.\", playerColor)\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat to the first empty spot from the right \n ---@param matColor string Playermat that triggered this\n ---@param position tts__Vector Position for the encounter card\n MythosAreaApi.drawEncounterCard = function(matColor, position)\n getMythosArea().call(\"drawEncounterCard\", { matColor = matColor, position = position })\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -97105,7 +97423,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"05313\",\n \"type\": \"Asset\",\n \"slot\": \"Accessory\",\n \"class\": \"Guardian\",\n \"cost\": 2,\n \"level\": 0,\n \"traits\": \"Item. Relic. Occult. Blessed.\",\n \"bonded\": [\n {\n \"count\": 3,\n \"id\": \"05314\"\n }\n ],\n \"willpowerIcons\": 1,\n \"cycle\": \"The Circle Undone\"\n}", + "GMNotes": "{\n \"id\": \"05313\",\n \"type\": \"Asset\",\n \"slot\": \"Accessory\",\n \"class\": \"Guardian\",\n \"cost\": 2,\n \"level\": 0,\n \"traits\": \"Item. Relic. Occult. Blessed.\",\n \"bonded\": [\n {\n \"count\": 3,\n \"maxCount\": 3,\n \"id\": \"05314\"\n }\n ],\n \"willpowerIcons\": 1,\n \"cycle\": \"The Circle Undone\"\n}", "GUID": "312d38", "Grid": true, "GridProjection": false, @@ -97167,7 +97485,7 @@ }, "Description": "Cat General of Ulthar", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"06030\",\n \"type\": \"Asset\",\n \"slot\": \"Ally\",\n \"class\": \"Survivor\",\n \"cost\": 3,\n \"level\": 1,\n \"traits\": \"Ally. Creature. Dreamlands.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"06031\"\n },\n {\n \"count\": 1,\n \"id\": \"06032\"\n },\n {\n \"count\": 1,\n \"id\": \"06033\"\n }\n ],\n \"wildIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", + "GMNotes": "{\n \"id\": \"06030\",\n \"type\": \"Asset\",\n \"slot\": \"Ally\",\n \"class\": \"Survivor\",\n \"cost\": 3,\n \"level\": 1,\n \"traits\": \"Ally. Creature. Dreamlands.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"06031\"\n },\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"06032\"\n },\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"06033\"\n }\n ],\n \"wildIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", "GUID": "e1aedf", "Grid": true, "GridProjection": false, @@ -97474,7 +97792,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"54004\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 3,\n \"traits\": \"Item. Tome. Occult.\",\n \"bonded\": [\n {\n \"count\": 3,\n \"id\": \"05317\"\n }\n ],\n \"intellectIcons\": 2,\n \"cycle\": \"Return to the Circle Undone\"\n}", + "GMNotes": "{\n \"id\": \"54004\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 3,\n \"traits\": \"Item. Tome. Occult.\",\n \"bonded\": [\n {\n \"count\": 3,\n \"maxCount\": 3,\n \"id\": \"05317\"\n }\n ],\n \"intellectIcons\": 2,\n \"cycle\": \"Return to the Circle Undone\"\n}", "GUID": "71d99c", "Grid": true, "GridProjection": false, @@ -99578,7 +99896,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/CrystallineElderSign3\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/CrystallineElderSign3\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"+1\"] = true,\n [\"Elder Sign\"] = true\n}\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/CrystallineElderSign3\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"playercards/cards/CrystallineElderSign3\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"+1\"] = true,\n [\"Elder Sign\"] = true\n}\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -100071,7 +100389,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/WellConnected\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/cards/WellConnected\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between both the level 0 and the upgraded level 3 version of the card\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nlocal modValue, loopId\nlocal buttonParameters = {\n click_function = \"toggleCounter\",\n tooltip = \"disable counter\",\n function_owner = self,\n position = { 0.88, 0.5, -1.33 },\n font_size = 150,\n width = 175,\n height = 175\n}\n\nfunction onSave() return JSON.encode({ loopId = loopId }) end\n\nfunction onLoad(savedData)\n -- use metadata to detect level and adjust modValue accordingly\n if JSON.decode(self.getGMNotes()).level == 0 then\n modValue = 5\n else\n modValue = 4\n end\n\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.loopId then\n self.createButton(buttonParameters)\n loopId = Wait.time(updateDisplay, 2, -1)\n end\n end\n\n self.addContextMenuItem(\"Toggle Counter\", toggleCounter)\nend\n\nfunction toggleCounter()\n if loopId ~= nil then\n Wait.stop(loopId)\n loopId = nil\n self.clearButtons()\n else\n self.createButton(buttonParameters)\n updateDisplay()\n loopId = Wait.time(updateDisplay, 2, -1)\n end\nend\n\nfunction updateDisplay()\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n local resources = playmatApi.getCounterValue(matColor, \"ResourceCounter\")\n local count = tostring(math.floor(resources / modValue))\n self.editButton({ index = 0, label = count })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/cards/WellConnected\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between both the level 0 and the upgraded level 3 version of the card\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nlocal modValue, loopId\nlocal buttonParameters = {\n click_function = \"toggleCounter\",\n tooltip = \"disable counter\",\n function_owner = self,\n position = { 0.88, 0.5, -1.33 },\n font_size = 150,\n width = 175,\n height = 175\n}\n\nfunction onSave() return JSON.encode({ loopId = loopId }) end\n\nfunction onLoad(savedData)\n -- use metadata to detect level and adjust modValue accordingly\n if JSON.decode(self.getGMNotes()).level == 0 then\n modValue = 5\n else\n modValue = 4\n end\n\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.loopId then\n self.createButton(buttonParameters)\n loopId = Wait.time(updateDisplay, 2, -1)\n end\n end\n\n self.addContextMenuItem(\"Toggle Counter\", toggleCounter)\nend\n\nfunction toggleCounter()\n if loopId ~= nil then\n Wait.stop(loopId)\n loopId = nil\n self.clearButtons()\n else\n self.createButton(buttonParameters)\n updateDisplay()\n loopId = Wait.time(updateDisplay, 2, -1)\n end\nend\n\nfunction updateDisplay()\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n local resources = playmatApi.getCounterValue(matColor, \"ResourceCounter\")\n local count = tostring(math.floor(resources / modValue))\n self.editButton({ index = 0, label = count })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/WellConnected\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -100680,7 +100998,7 @@ }, "Description": "Dreams of a Child", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"06238\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 3,\n \"traits\": \"Item. Tome. Charm.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"06113\"\n }\n ],\n \"willpowerIcons\": 1,\n \"intellectIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", + "GMNotes": "{\n \"id\": \"06238\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 3,\n \"traits\": \"Item. Tome. Charm.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"06113\"\n }\n ],\n \"willpowerIcons\": 1,\n \"intellectIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", "GUID": "ea40f6", "Grid": true, "GridProjection": false, @@ -104195,7 +104513,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ShieldofFaith2\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/ShieldofFaith2\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Bless\"] = true\n}\n\nSHOW_SINGLE_RELEASE = true\nKEEP_OPEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ShieldofFaith2\")\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"playercards/cards/ShieldofFaith2\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Bless\"] = true\n}\n\nKEEP_OPEN = true\nSHOW_SINGLE_RELEASE = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -106587,7 +106905,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ScrollofSecrets\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat\n ---@param mat tts__Object Playermat that triggered this\n ---@param alwaysFaceUp boolean Whether the card should be drawn face-up\n MythosAreaApi.drawEncounterCard = function(mat, alwaysFaceUp)\n getMythosArea().call(\"drawEncounterCard\", {mat = mat, alwaysFaceUp = alwaysFaceUp})\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"playercards/cards/ScrollofSecrets\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between the lvl 0 and lvl 3 versions of Scroll of Secrets\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- get class via metadata and create context menu accordingly\nfunction onLoad()\n local notes = JSON.decode(self.getGMNotes())\n if notes then\n createContextMenu(notes.id)\n else\n print(\"Missing metadata for Scroll of Secrets!\")\n end\nend\n\nfunction createContextMenu(id)\n if id == \"05116\" or id == \"05116-t\" then\n -- lvl 0: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n elseif id == \"05188\" or id == \"05188-t\" then\n -- seeker lvl 3: draw 3 cards from the bottom\n self.addContextMenuItem(\"Draw bottom card(s)\", function(playerColor) contextFunc(playerColor, 3) end)\n elseif id == \"05189\" or id == \"05189-t\" then\n -- mystic lvl 3: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n end\nend\n\nfunction contextFunc(playerColor, amount)\n local options = { \"Encounter Deck\" }\n\n -- check for players with a deck and only display them as option\n for _, color in ipairs(Player.getAvailableColors()) do\n local matColor = playmatApi.getMatColor(color)\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n\n if deckAreaObjects.draw or deckAreaObjects.topCard then\n table.insert(options, color)\n end\n end\n\n -- show the target selection dialog\n Player[playerColor].showOptionsDialog(\"Select target deck\", options, _, function(owner) drawCardsFromBottom(playerColor, owner, amount) end)\nend\n\nfunction drawCardsFromBottom(playerColor, owner, amount)\n -- variable initialization\n local deck = nil\n local deckSize = 1\n local deckAreaObjects = {}\n\n -- get the respective deck\n if owner == \"Encounter Deck\" then\n deck = mythosAreaApi.getEncounterDeck()\n else\n local matColor = playmatApi.getMatColor(owner)\n deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n deck = deckAreaObjects.draw\n end\n\n -- error handling\n if not deck then\n printToColor(\"Couldn't find deck!\", playerColor)\n return\n end\n\n -- set deck size if there is actually a deck and not just a card\n if deck.type == \"Deck\" then\n deckSize = #deck.getObjects()\n end\n\n -- proceed according to deck size\n if deckSize \u003e amount then\n for i = 1, amount do\n local card = deck.takeObject({ top = false, flip = true })\n card.deal(1, playerColor)\n end\n else\n -- deal the whole deck\n deck.deal(amount, playerColor)\n\n if deckSize \u003c amount then\n -- Norman Withers handling\n if deckAreaObjects.topCard then\n deckAreaObjects.topCard.deal(1, playerColor)\n deckSize = deckSize + 1\n end\n\n -- warning message for player\n if deckSize \u003c amount then\n printToColor(\"Deck didn't contain enough cards.\", playerColor)\n end\n end\n end\n printToColor(\"Handle the drawn cards according to the ability text on 'Scroll of Secrets'.\", playerColor)\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ScrollofSecrets\")\nend)\n__bundle_register(\"playercards/cards/ScrollofSecrets\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between the lvl 0 and lvl 3 versions of Scroll of Secrets\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- get class via metadata and create context menu accordingly\nfunction onLoad()\n local notes = JSON.decode(self.getGMNotes())\n if notes then\n createContextMenu(notes.id)\n else\n print(\"Missing metadata for Scroll of Secrets!\")\n end\nend\n\nfunction createContextMenu(id)\n if id == \"05116\" or id == \"05116-t\" then\n -- lvl 0: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n elseif id == \"05188\" or id == \"05188-t\" then\n -- seeker lvl 3: draw 3 cards from the bottom\n self.addContextMenuItem(\"Draw bottom card(s)\", function(playerColor) contextFunc(playerColor, 3) end)\n elseif id == \"05189\" or id == \"05189-t\" then\n -- mystic lvl 3: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n end\nend\n\nfunction contextFunc(playerColor, amount)\n local options = { \"Encounter Deck\" }\n\n -- check for players with a deck and only display them as option\n for _, color in ipairs(Player.getAvailableColors()) do\n local matColor = playmatApi.getMatColor(color)\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n\n if deckAreaObjects.draw or deckAreaObjects.topCard then\n table.insert(options, color)\n end\n end\n\n -- show the target selection dialog\n Player[playerColor].showOptionsDialog(\"Select target deck\", options, _, function(owner) drawCardsFromBottom(playerColor, owner, amount) end)\nend\n\nfunction drawCardsFromBottom(playerColor, owner, amount)\n -- variable initialization\n local deck = nil\n local deckSize = 1\n local deckAreaObjects = {}\n\n -- get the respective deck\n if owner == \"Encounter Deck\" then\n deck = mythosAreaApi.getEncounterDeck()\n else\n local matColor = playmatApi.getMatColor(owner)\n deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n deck = deckAreaObjects.draw\n end\n\n -- error handling\n if not deck then\n printToColor(\"Couldn't find deck!\", playerColor)\n return\n end\n\n -- set deck size if there is actually a deck and not just a card\n if deck.type == \"Deck\" then\n deckSize = #deck.getObjects()\n end\n\n -- proceed according to deck size\n if deckSize \u003e amount then\n for i = 1, amount do\n local card = deck.takeObject({ top = false, flip = true })\n card.deal(1, playerColor)\n end\n else\n -- deal the whole deck\n deck.deal(amount, playerColor)\n\n if deckSize \u003c amount then\n -- Norman Withers handling\n if deckAreaObjects.topCard then\n deckAreaObjects.topCard.deal(1, playerColor)\n deckSize = deckSize + 1\n end\n\n -- warning message for player\n if deckSize \u003c amount then\n printToColor(\"Deck didn't contain enough cards.\", playerColor)\n end\n end\n end\n printToColor(\"Handle the drawn cards according to the ability text on 'Scroll of Secrets'.\", playerColor)\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat to the first empty spot from the right \n ---@param matColor string Playermat that triggered this\n ---@param position tts__Vector Position for the encounter card\n MythosAreaApi.drawEncounterCard = function(matColor, position)\n getMythosArea().call(\"drawEncounterCard\", { matColor = matColor, position = position })\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -107316,7 +107634,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"06282\",\n \"type\": \"Asset\",\n \"slot\": \"Ally|Arcane\",\n \"class\": \"Mystic\",\n \"cost\": 3,\n \"level\": 1,\n \"traits\": \"Ally. Summon.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"06283\"\n }\n ],\n \"intellectIcons\": 1,\n \"combatIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", + "GMNotes": "{\n \"id\": \"06282\",\n \"type\": \"Asset\",\n \"slot\": \"Ally|Arcane\",\n \"class\": \"Mystic\",\n \"cost\": 3,\n \"level\": 1,\n \"traits\": \"Ally. Summon.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 2,\n \"id\": \"06283\"\n }\n ],\n \"intellectIcons\": 1,\n \"combatIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", "GUID": "ab4fb3", "Grid": true, "GridProjection": false, @@ -107789,19 +108107,19 @@ "z": 0 }, "Autoraise": true, - "CardID": 546500, + "CardID": 553105, "ColorDiffuse": { "b": 0.71324, "g": 0.71324, "r": 0.71324 }, "CustomDeck": { - "5465": { + "5531": { "BackIsHidden": true, "BackURL": "http://cloud-3.steamusercontent.com/ugc/2342503777940352139/A2D42E7E5C43D045D72CE5CFC907E4F886C8C690/", - "FaceURL": "http://cloud-3.steamusercontent.com/ugc/1597044073918730883/0E7FEB9CC85CD11EB5194774E90A73163EDACBEC/", - "NumHeight": 1, - "NumWidth": 1, + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/1684870715280867313/BFD2AF968EAC917D3B838DCB8B1656941CD8B5CC/", + "NumHeight": 7, + "NumWidth": 10, "Type": 0, "UniqueBack": false } @@ -108680,7 +108998,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/RiteofSanctification\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/RiteofSanctification\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Bless\"] = true\n}\n\nSHOW_SINGLE_RELEASE = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"playercards/cards/RiteofSanctification\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Bless\"] = true\n}\n\nKEEP_OPEN = true\nSHOW_SINGLE_RELEASE = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/RiteofSanctification\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -109297,7 +109615,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/TheCodexofAges\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/TheCodexofAges\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Elder Sign\"] = true\n}\n\nRESOLVE_TOKEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/TheCodexofAges\")\nend)\n__bundle_register(\"playercards/cards/TheCodexofAges\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Elder Sign\"] = true\n}\n\nRESOLVE_TOKEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -110284,7 +110602,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ProtectiveIncantation1\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/ProtectiveIncantation1\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {}\n\nINVALID_TOKENS = {\n [\"Auto-fail\"] = true\n}\n\nUPDATE_ON_HOVER = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ProtectiveIncantation1\")\nend)\n__bundle_register(\"playercards/cards/ProtectiveIncantation1\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {}\n\nINVALID_TOKENS = {\n [\"Auto-fail\"] = true\n}\n\nUPDATE_ON_HOVER = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -110900,7 +111218,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/FavoroftheMoon1\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/FavoroftheMoon1\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Curse\"] = true\n}\n\nSHOW_SINGLE_RELEASE = true\nKEEP_OPEN = true\nRESOLVE_TOKEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/FavoroftheMoon1\")\nend)\n__bundle_register(\"playercards/cards/FavoroftheMoon1\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Curse\"] = true\n}\n\nSHOW_SINGLE_RELEASE = true\nKEEP_OPEN = true\nRESOLVE_TOKEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -111886,7 +112204,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ScrollofSecrets\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat\n ---@param mat tts__Object Playermat that triggered this\n ---@param alwaysFaceUp boolean Whether the card should be drawn face-up\n MythosAreaApi.drawEncounterCard = function(mat, alwaysFaceUp)\n getMythosArea().call(\"drawEncounterCard\", {mat = mat, alwaysFaceUp = alwaysFaceUp})\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"playercards/cards/ScrollofSecrets\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between the lvl 0 and lvl 3 versions of Scroll of Secrets\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- get class via metadata and create context menu accordingly\nfunction onLoad()\n local notes = JSON.decode(self.getGMNotes())\n if notes then\n createContextMenu(notes.id)\n else\n print(\"Missing metadata for Scroll of Secrets!\")\n end\nend\n\nfunction createContextMenu(id)\n if id == \"05116\" or id == \"05116-t\" then\n -- lvl 0: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n elseif id == \"05188\" or id == \"05188-t\" then\n -- seeker lvl 3: draw 3 cards from the bottom\n self.addContextMenuItem(\"Draw bottom card(s)\", function(playerColor) contextFunc(playerColor, 3) end)\n elseif id == \"05189\" or id == \"05189-t\" then\n -- mystic lvl 3: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n end\nend\n\nfunction contextFunc(playerColor, amount)\n local options = { \"Encounter Deck\" }\n\n -- check for players with a deck and only display them as option\n for _, color in ipairs(Player.getAvailableColors()) do\n local matColor = playmatApi.getMatColor(color)\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n\n if deckAreaObjects.draw or deckAreaObjects.topCard then\n table.insert(options, color)\n end\n end\n\n -- show the target selection dialog\n Player[playerColor].showOptionsDialog(\"Select target deck\", options, _, function(owner) drawCardsFromBottom(playerColor, owner, amount) end)\nend\n\nfunction drawCardsFromBottom(playerColor, owner, amount)\n -- variable initialization\n local deck = nil\n local deckSize = 1\n local deckAreaObjects = {}\n\n -- get the respective deck\n if owner == \"Encounter Deck\" then\n deck = mythosAreaApi.getEncounterDeck()\n else\n local matColor = playmatApi.getMatColor(owner)\n deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n deck = deckAreaObjects.draw\n end\n\n -- error handling\n if not deck then\n printToColor(\"Couldn't find deck!\", playerColor)\n return\n end\n\n -- set deck size if there is actually a deck and not just a card\n if deck.type == \"Deck\" then\n deckSize = #deck.getObjects()\n end\n\n -- proceed according to deck size\n if deckSize \u003e amount then\n for i = 1, amount do\n local card = deck.takeObject({ top = false, flip = true })\n card.deal(1, playerColor)\n end\n else\n -- deal the whole deck\n deck.deal(amount, playerColor)\n\n if deckSize \u003c amount then\n -- Norman Withers handling\n if deckAreaObjects.topCard then\n deckAreaObjects.topCard.deal(1, playerColor)\n deckSize = deckSize + 1\n end\n\n -- warning message for player\n if deckSize \u003c amount then\n printToColor(\"Deck didn't contain enough cards.\", playerColor)\n end\n end\n end\n printToColor(\"Handle the drawn cards according to the ability text on 'Scroll of Secrets'.\", playerColor)\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ScrollofSecrets\")\nend)\n__bundle_register(\"playercards/cards/ScrollofSecrets\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between the lvl 0 and lvl 3 versions of Scroll of Secrets\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- get class via metadata and create context menu accordingly\nfunction onLoad()\n local notes = JSON.decode(self.getGMNotes())\n if notes then\n createContextMenu(notes.id)\n else\n print(\"Missing metadata for Scroll of Secrets!\")\n end\nend\n\nfunction createContextMenu(id)\n if id == \"05116\" or id == \"05116-t\" then\n -- lvl 0: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n elseif id == \"05188\" or id == \"05188-t\" then\n -- seeker lvl 3: draw 3 cards from the bottom\n self.addContextMenuItem(\"Draw bottom card(s)\", function(playerColor) contextFunc(playerColor, 3) end)\n elseif id == \"05189\" or id == \"05189-t\" then\n -- mystic lvl 3: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n end\nend\n\nfunction contextFunc(playerColor, amount)\n local options = { \"Encounter Deck\" }\n\n -- check for players with a deck and only display them as option\n for _, color in ipairs(Player.getAvailableColors()) do\n local matColor = playmatApi.getMatColor(color)\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n\n if deckAreaObjects.draw or deckAreaObjects.topCard then\n table.insert(options, color)\n end\n end\n\n -- show the target selection dialog\n Player[playerColor].showOptionsDialog(\"Select target deck\", options, _, function(owner) drawCardsFromBottom(playerColor, owner, amount) end)\nend\n\nfunction drawCardsFromBottom(playerColor, owner, amount)\n -- variable initialization\n local deck = nil\n local deckSize = 1\n local deckAreaObjects = {}\n\n -- get the respective deck\n if owner == \"Encounter Deck\" then\n deck = mythosAreaApi.getEncounterDeck()\n else\n local matColor = playmatApi.getMatColor(owner)\n deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n deck = deckAreaObjects.draw\n end\n\n -- error handling\n if not deck then\n printToColor(\"Couldn't find deck!\", playerColor)\n return\n end\n\n -- set deck size if there is actually a deck and not just a card\n if deck.type == \"Deck\" then\n deckSize = #deck.getObjects()\n end\n\n -- proceed according to deck size\n if deckSize \u003e amount then\n for i = 1, amount do\n local card = deck.takeObject({ top = false, flip = true })\n card.deal(1, playerColor)\n end\n else\n -- deal the whole deck\n deck.deal(amount, playerColor)\n\n if deckSize \u003c amount then\n -- Norman Withers handling\n if deckAreaObjects.topCard then\n deckAreaObjects.topCard.deal(1, playerColor)\n deckSize = deckSize + 1\n end\n\n -- warning message for player\n if deckSize \u003c amount then\n printToColor(\"Deck didn't contain enough cards.\", playerColor)\n end\n end\n end\n printToColor(\"Handle the drawn cards according to the ability text on 'Scroll of Secrets'.\", playerColor)\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat to the first empty spot from the right \n ---@param matColor string Playermat that triggered this\n ---@param position tts__Vector Position for the encounter card\n MythosAreaApi.drawEncounterCard = function(matColor, position)\n getMythosArea().call(\"drawEncounterCard\", { matColor = matColor, position = position })\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -111948,7 +112266,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/Nephthys4\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/Nephthys4\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Bless\"] = true\n}\n\nSHOW_MULTI_RELEASE = 3\nSHOW_MULTI_RETURN = 3\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/Nephthys4\")\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"playercards/cards/Nephthys4\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Bless\"] = true\n}\n\nSHOW_SINGLE_RELEASE = true\nSHOW_MULTI_RELEASE = 3\nSHOW_MULTI_RETURN = 3\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -112873,7 +113191,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/Unrelenting1\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/Unrelenting1\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {}\nINVALID_TOKENS = {\n [\"Auto-fail\"] = true\n}\n\nUPDATE_ON_HOVER = true\nKEEP_OPEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/Unrelenting1\")\nend)\n__bundle_register(\"playercards/cards/Unrelenting1\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {}\nINVALID_TOKENS = {\n [\"Auto-fail\"] = true\n}\n\nUPDATE_ON_HOVER = true\nKEEP_OPEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -113660,7 +113978,7 @@ }, "Description": "Untranslated", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"06112\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 0,\n \"traits\": \"Item. Tome. Charm.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"06113\"\n }\n ],\n \"willpowerIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", + "GMNotes": "{\n \"id\": \"06112\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 0,\n \"traits\": \"Item. Tome. Charm.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"06113\"\n }\n ],\n \"willpowerIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", "GUID": "b81dcf", "Grid": true, "GridProjection": false, @@ -115566,7 +115884,7 @@ }, "Description": "Abandoned by the Gods", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"06276\",\n \"type\": \"Asset\",\n \"slot\": \"Accessory\",\n \"class\": \"Guardian\",\n \"cost\": 1,\n \"level\": 4,\n \"traits\": \"Item. Relic. Blessed.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"06277\"\n }\n ],\n \"willpowerIcons\": 1,\n \"wildIcons\": 1,\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Charge\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Dream-Eaters\"\n}", + "GMNotes": "{\n \"id\": \"06276\",\n \"type\": \"Asset\",\n \"slot\": \"Accessory\",\n \"class\": \"Guardian\",\n \"cost\": 1,\n \"level\": 4,\n \"traits\": \"Item. Relic. Blessed.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"06277\"\n }\n ],\n \"willpowerIcons\": 1,\n \"wildIcons\": 1,\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Charge\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Dream-Eaters\"\n}", "GUID": "c0d236", "Grid": true, "GridProjection": false, @@ -116068,7 +116386,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/TheChthonianStone3\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/TheChthonianStone3\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n}\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/cards/TheChthonianStone3\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n}\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/TheChthonianStone3\")\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -119014,7 +119332,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"05316\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 0,\n \"traits\": \"Item. Tome. Occult.\",\n \"bonded\": [\n {\n \"count\": 3,\n \"id\": \"05317\"\n }\n ],\n \"intellectIcons\": 1,\n \"cycle\": \"The Circle Undone\"\n}", + "GMNotes": "{\n \"id\": \"05316\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 0,\n \"traits\": \"Item. Tome. Occult.\",\n \"bonded\": [\n {\n \"count\": 3,\n \"maxCount\": 3,\n \"id\": \"05317\"\n }\n ],\n \"intellectIcons\": 1,\n \"cycle\": \"The Circle Undone\"\n}", "GUID": "5d6728", "Grid": true, "GridProjection": false, @@ -119876,7 +120194,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"54002\",\n \"type\": \"Asset\",\n \"slot\": \"Accessory\",\n \"class\": \"Guardian\",\n \"cost\": 2,\n \"level\": 3,\n \"traits\": \"Item. Relic. Occult. Blessed.\",\n \"bonded\": [\n {\n \"count\": 3,\n \"id\": \"05314\"\n }\n ],\n \"willpowerIcons\": 2,\n \"cycle\": \"Return to the Circle Undone\"\n}", + "GMNotes": "{\n \"id\": \"54002\",\n \"type\": \"Asset\",\n \"slot\": \"Accessory\",\n \"class\": \"Guardian\",\n \"cost\": 2,\n \"level\": 3,\n \"traits\": \"Item. Relic. Occult. Blessed.\",\n \"bonded\": [\n {\n \"count\": 3,\n \"maxCount\": 3,\n \"id\": \"05314\"\n }\n ],\n \"willpowerIcons\": 2,\n \"cycle\": \"Return to the Circle Undone\"\n}", "GUID": "78858f", "Grid": true, "GridProjection": false, @@ -123814,7 +124132,7 @@ }, "Description": "Worlds within Worlds", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"06013\",\n \"type\": \"Asset\",\n \"class\": \"Neutral\",\n \"startsInPlay\": true,\n \"cost\": 3,\n \"traits\": \"Item. Relic.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"06015a\"\n }\n ],\n \"uses\": [\n {\n \"count\": 3,\n \"type\": \"Charge\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Dream-Eaters\"\n}", + "GMNotes": "{\n \"id\": \"06013\",\n \"type\": \"Asset\",\n \"class\": \"Neutral\",\n \"startsInPlay\": true,\n \"cost\": 3,\n \"traits\": \"Item. Relic.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"06015a\"\n }\n ],\n \"uses\": [\n {\n \"count\": 3,\n \"type\": \"Charge\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Dream-Eaters\"\n}", "GUID": "b8c891", "Grid": true, "GridProjection": false, @@ -124677,7 +124995,7 @@ }, "Description": "Dreams of an Explorer", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"06236\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 3,\n \"traits\": \"Item. Tome. Charm.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"06113\"\n }\n ],\n \"willpowerIcons\": 1,\n \"agilityIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", + "GMNotes": "{\n \"id\": \"06236\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 3,\n \"traits\": \"Item. Tome. Charm.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"06113\"\n }\n ],\n \"willpowerIcons\": 1,\n \"agilityIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", "GUID": "5f9a10", "Grid": true, "GridProjection": false, @@ -125665,7 +125983,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"06027\",\n \"type\": \"Event\",\n \"class\": \"Mystic\",\n \"cost\": 0,\n \"level\": 1,\n \"traits\": \"Insight. Augury.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"06028\"\n }\n ],\n \"wildIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", + "GMNotes": "{\n \"id\": \"06027\",\n \"type\": \"Event\",\n \"class\": \"Mystic\",\n \"cost\": 0,\n \"level\": 1,\n \"traits\": \"Insight. Augury.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 2,\n \"id\": \"06028\"\n }\n ],\n \"wildIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", "GUID": "968a26", "Grid": true, "GridProjection": false, @@ -127331,7 +127649,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/FavoroftheSun1\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/FavoroftheSun1\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Bless\"] = true\n}\n\nSHOW_SINGLE_RELEASE = true\nKEEP_OPEN = true\nRESOLVE_TOKEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/FavoroftheSun1\")\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"playercards/cards/FavoroftheSun1\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Bless\"] = true\n}\n\nSHOW_SINGLE_RELEASE = true\nKEEP_OPEN = true\nRESOLVE_TOKEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -128073,7 +128391,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/WellConnected\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/cards/WellConnected\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between both the level 0 and the upgraded level 3 version of the card\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nlocal modValue, loopId\nlocal buttonParameters = {\n click_function = \"toggleCounter\",\n tooltip = \"disable counter\",\n function_owner = self,\n position = { 0.88, 0.5, -1.33 },\n font_size = 150,\n width = 175,\n height = 175\n}\n\nfunction onSave() return JSON.encode({ loopId = loopId }) end\n\nfunction onLoad(savedData)\n -- use metadata to detect level and adjust modValue accordingly\n if JSON.decode(self.getGMNotes()).level == 0 then\n modValue = 5\n else\n modValue = 4\n end\n\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.loopId then\n self.createButton(buttonParameters)\n loopId = Wait.time(updateDisplay, 2, -1)\n end\n end\n\n self.addContextMenuItem(\"Toggle Counter\", toggleCounter)\nend\n\nfunction toggleCounter()\n if loopId ~= nil then\n Wait.stop(loopId)\n loopId = nil\n self.clearButtons()\n else\n self.createButton(buttonParameters)\n updateDisplay()\n loopId = Wait.time(updateDisplay, 2, -1)\n end\nend\n\nfunction updateDisplay()\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n local resources = playmatApi.getCounterValue(matColor, \"ResourceCounter\")\n local count = tostring(math.floor(resources / modValue))\n self.editButton({ index = 0, label = count })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/WellConnected\")\nend)\n__bundle_register(\"playercards/cards/WellConnected\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between both the level 0 and the upgraded level 3 version of the card\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nlocal modValue, loopId\nlocal buttonParameters = {\n click_function = \"toggleCounter\",\n tooltip = \"disable counter\",\n function_owner = self,\n position = { 0.88, 0.5, -1.33 },\n font_size = 150,\n width = 175,\n height = 175\n}\n\nfunction onSave() return JSON.encode({ loopId = loopId }) end\n\nfunction onLoad(savedData)\n -- use metadata to detect level and adjust modValue accordingly\n if JSON.decode(self.getGMNotes()).level == 0 then\n modValue = 5\n else\n modValue = 4\n end\n\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.loopId then\n self.createButton(buttonParameters)\n loopId = Wait.time(updateDisplay, 2, -1)\n end\n end\n\n self.addContextMenuItem(\"Toggle Counter\", toggleCounter)\nend\n\nfunction toggleCounter()\n if loopId ~= nil then\n Wait.stop(loopId)\n loopId = nil\n self.clearButtons()\n else\n self.createButton(buttonParameters)\n updateDisplay()\n loopId = Wait.time(updateDisplay, 2, -1)\n end\nend\n\nfunction updateDisplay()\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n local resources = playmatApi.getCounterValue(matColor, \"ResourceCounter\")\n local count = tostring(math.floor(resources / modValue))\n self.editButton({ index = 0, label = count })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -128873,7 +129191,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/TheChthonianStone\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/TheChthonianStone\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n}\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/TheChthonianStone\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/cards/TheChthonianStone\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n}\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -134539,7 +134857,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/HolySpear5\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/HolySpear5\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Bless\"] = true\n}\n\nSHOW_SINGLE_RELEASE = true\nSHOW_MULTI_SEAL = 2\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/cards/HolySpear5\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Bless\"] = true\n}\n\nSHOW_SINGLE_RELEASE = true\nSHOW_MULTI_SEAL = 2\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/HolySpear5\")\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -135639,7 +135957,7 @@ }, "Description": "Calamitous Blade of Celephaïs", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"06018\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Guardian\",\n \"cost\": 3,\n \"level\": 1,\n \"traits\": \"Item. Weapon. Melee. Relic. Cursed.\",\n \"bonded\": [\n {\n \"count\": 3,\n \"id\": \"06019\"\n }\n ],\n \"combatIcons\": 1,\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Offering\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Dream-Eaters\"\n}", + "GMNotes": "{\n \"id\": \"06018\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Guardian\",\n \"cost\": 3,\n \"level\": 1,\n \"traits\": \"Item. Weapon. Melee. Relic. Cursed.\",\n \"bonded\": [\n {\n \"count\": 3,\n \"maxCount\": 3,\n \"id\": \"06019\"\n }\n ],\n \"combatIcons\": 1,\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Offering\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Dream-Eaters\"\n}", "GUID": "2d94ed", "Grid": true, "GridProjection": false, @@ -137237,7 +137555,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"06021\",\n \"type\": \"Asset\",\n \"class\": \"Seeker\",\n \"cost\": 1,\n \"level\": 1,\n \"traits\": \"Item. Relic. Occult.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"06022\"\n }\n ],\n \"wildIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", + "GMNotes": "{\n \"id\": \"06021\",\n \"type\": \"Asset\",\n \"class\": \"Seeker\",\n \"cost\": 1,\n \"level\": 1,\n \"traits\": \"Item. Relic. Occult.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"06022\"\n }\n ],\n \"wildIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", "GUID": "ff9f23", "Grid": true, "GridProjection": false, @@ -141557,7 +141875,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/SerpentsofYig\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/SerpentsofYig\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Elder Sign\"] = true\n}\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/SerpentsofYig\")\nend)\n__bundle_register(\"playercards/cards/SerpentsofYig\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Elder Sign\"] = true\n}\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -142048,7 +142366,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/SealoftheSeventhSign5\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/SealoftheSeventhSign5\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Auto-fail\"] = true\n}\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/SealoftheSeventhSign5\")\nend)\n__bundle_register(\"playercards/cards/SealoftheSeventhSign5\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Auto-fail\"] = true\n}\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -142970,7 +143288,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/RadiantSmite1\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/RadiantSmite1\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Bless\"] = true\n}\n\nKEEP_OPEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/RadiantSmite1\")\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"playercards/cards/RadiantSmite1\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Bless\"] = true\n}\n\nKEEP_OPEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -144048,19 +144366,19 @@ "z": 0 }, "Autoraise": true, - "CardID": 546400, + "CardID": 553114, "ColorDiffuse": { "b": 0.71324, "g": 0.71324, "r": 0.71324 }, "CustomDeck": { - "5464": { + "5531": { "BackIsHidden": true, "BackURL": "http://cloud-3.steamusercontent.com/ugc/2342503777940352139/A2D42E7E5C43D045D72CE5CFC907E4F886C8C690/", - "FaceURL": "http://cloud-3.steamusercontent.com/ugc/1597044073918730334/45D2725C3553953A73DAFBEF631E78D459716EA7/", - "NumHeight": 1, - "NumWidth": 1, + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/1684870715280867313/BFD2AF968EAC917D3B838DCB8B1656941CD8B5CC/", + "NumHeight": 7, + "NumWidth": 10, "Type": 0, "UniqueBack": false } @@ -144129,7 +144447,7 @@ }, "Description": "Dreams of a Madman", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"06237\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 3,\n \"traits\": \"Item. Tome. Charm.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"06113\"\n }\n ],\n \"willpowerIcons\": 1,\n \"combatIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", + "GMNotes": "{\n \"id\": \"06237\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 3,\n \"traits\": \"Item. Tome. Charm.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"06113\"\n }\n ],\n \"willpowerIcons\": 1,\n \"combatIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", "GUID": "e5f9cb", "Grid": true, "GridProjection": false, @@ -144507,7 +144825,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/DayofReckoning\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/DayofReckoning\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Elder Sign\"] = true\n}\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"playercards/cards/DayofReckoning\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Elder Sign\"] = true\n}\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/DayofReckoning\")\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -144682,7 +145000,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"06024\",\n \"type\": \"Asset\",\n \"slot\": \"Accessory\",\n \"class\": \"Rogue\",\n \"cost\": 1,\n \"level\": 0,\n \"traits\": \"Item. Relic.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"06025\"\n }\n ],\n \"willpowerIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", + "GMNotes": "{\n \"id\": \"06024\",\n \"type\": \"Asset\",\n \"slot\": \"Accessory\",\n \"class\": \"Rogue\",\n \"cost\": 1,\n \"level\": 0,\n \"traits\": \"Item. Relic.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 2,\n \"id\": \"06025\"\n }\n ],\n \"willpowerIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", "GUID": "6692de", "Grid": true, "GridProjection": false, @@ -145670,7 +145988,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"06330\",\n \"type\": \"Asset\",\n \"slot\": \"Accessory\",\n \"class\": \"Survivor\",\n \"cost\": 1,\n \"level\": 3,\n \"traits\": \"Item. Charm. Cursed.\",\n \"bonded\": [\n {\n \"count\": 3,\n \"id\": \"06331\"\n }\n ],\n \"willpowerIcons\": 1,\n \"wildIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", + "GMNotes": "{\n \"id\": \"06330\",\n \"type\": \"Asset\",\n \"slot\": \"Accessory\",\n \"class\": \"Survivor\",\n \"cost\": 1,\n \"level\": 3,\n \"traits\": \"Item. Charm. Cursed.\",\n \"bonded\": [\n {\n \"count\": 3,\n \"maxCount\": 3,\n \"id\": \"06331\"\n }\n ],\n \"willpowerIcons\": 1,\n \"wildIcons\": 1,\n \"cycle\": \"The Dream-Eaters\"\n}", "GUID": "d6f6f1", "Grid": true, "GridProjection": false, @@ -147648,7 +147966,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/DarkRitual\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/DarkRitual\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Curse\"] = true\n}\n\nKEEP_OPEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/DarkRitual\")\nend)\n__bundle_register(\"playercards/cards/DarkRitual\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Curse\"] = true\n}\n\nKEEP_OPEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -147893,7 +148211,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/FamilyInheritance\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror\n -- tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned) spawned.setState(tokenValue) end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"playercards/cards/FamilyInheritance\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenManager = require(\"core/token/TokenManager\")\n\nlocal clickableResourceCounter = nil\nlocal foundTokens = 0\n\nfunction onLoad()\n self.addContextMenuItem(\"Add 4 resources\", function(playerColor) add4(playerColor) end)\n self.addContextMenuItem(\"Take all resources\", function(playerColor) takeAll(playerColor) end)\n self.addContextMenuItem(\"Discard all resources\", function(playerColor) loseAll(playerColor) end)\nend\n\nfunction searchSelf()\n clickableResourceCounter = nil\n foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(self, \"isTileOrToken\")) do\n local image = obj.getCustomObject().image\n if image == \"http://cloud-3.steamusercontent.com/ugc/1758068501357192910/11DDDC7EF621320962FDCF3AE3211D5EDC3D1573/\" then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif obj.getMemo() == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n return\n end\n end\nend\n\nfunction add4(playerColor)\n searchSelf()\n\n local newCount = foundTokens + 4\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n if newCount \u003e 12 then\n printToColor(\"Count increased to \" .. newCount .. \" resources. Spawning clickable counter instead.\", playerColor)\n tokenManager.spawnResourceCounterToken(self, newCount)\n else\n tokenManager.spawnTokenGroup(self, \"resource\", newCount)\n end\n end\nend\n\nfunction takeAll(playerColor)\n searchSelf()\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n playmatApi.updateCounter(matColor, \"ResourceCounter\", _, foundTokens)\n\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", 0)\n end\n printToColor(\"Moved \" .. foundTokens .. \" resource(s) to \" .. matColor .. \"'s resource pool.\", playerColor)\nend\n\nfunction loseAll(playerColor)\n searchSelf()\n\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", 0)\n end\n printToColor(\"Discarded \" .. foundTokens .. \" resource(s).\", playerColor)\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/FamilyInheritance\")\nend)\n__bundle_register(\"playercards/cards/FamilyInheritance\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal tokenManager = require(\"core/token/TokenManager\")\n\nlocal clickableResourceCounter = nil\nlocal foundTokens = 0\n\nfunction onLoad()\n self.addContextMenuItem(\"Add 4 resources\", function(playerColor) add4(playerColor) end)\n self.addContextMenuItem(\"Take all resources\", function(playerColor) takeAll(playerColor) end)\n self.addContextMenuItem(\"Discard all resources\", function(playerColor) loseAll(playerColor) end)\nend\n\nfunction searchSelf()\n clickableResourceCounter = nil\n foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(self, \"isTileOrToken\")) do\n local image = obj.getCustomObject().image\n if image == \"http://cloud-3.steamusercontent.com/ugc/1758068501357192910/11DDDC7EF621320962FDCF3AE3211D5EDC3D1573/\" then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif obj.getMemo() == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n return\n end\n end\nend\n\nfunction add4(playerColor)\n searchSelf()\n\n local newCount = foundTokens + 4\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n if newCount \u003e 12 then\n printToColor(\"Count increased to \" .. newCount .. \" resources. Spawning clickable counter instead.\", playerColor)\n tokenManager.spawnResourceCounterToken(self, newCount)\n else\n tokenManager.spawnTokenGroup(self, \"resource\", newCount)\n end\n end\nend\n\nfunction takeAll(playerColor)\n searchSelf()\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n playmatApi.updateCounter(matColor, \"ResourceCounter\", _, foundTokens)\n\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", 0)\n end\n printToColor(\"Moved \" .. foundTokens .. \" resource(s) to \" .. matColor .. \"'s resource pool.\", playerColor)\nend\n\nfunction loseAll(playerColor)\n searchSelf()\n\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", 0)\n end\n printToColor(\"Discarded \" .. foundTokens .. \" resource(s).\", playerColor)\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/token/TokenManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local optionPanelApi = require(\"core/OptionPanelApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n local searchLib = require(\"util/SearchLib\")\n local tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n local PLAYER_CARD_TOKEN_OFFSETS = {\n [1] = {\n Vector(0, 3, -0.2)\n },\n [2] = {\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [3] = {\n Vector(0, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [4] = {\n Vector(0.4, 3, -0.9),\n Vector(-0.4, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [5] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.4, 3, -0.2),\n Vector(-0.4, 3, -0.2)\n },\n [6] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2)\n },\n [7] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0, 3, 0.5)\n },\n [8] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(-0.35, 3, 0.5),\n Vector(0.35, 3, 0.5)\n },\n [9] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5)\n },\n [10] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0, 3, 1.2)\n },\n [11] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(-0.35, 3, 1.2),\n Vector(0.35, 3, 1.2)\n },\n [12] = {\n Vector(0.7, 3, -0.9),\n Vector(0, 3, -0.9),\n Vector(-0.7, 3, -0.9),\n Vector(0.7, 3, -0.2),\n Vector(0, 3, -0.2),\n Vector(-0.7, 3, -0.2),\n Vector(0.7, 3, 0.5),\n Vector(0, 3, 0.5),\n Vector(-0.7, 3, 0.5),\n Vector(0.7, 3, 1.2),\n Vector(0, 3, 1.2),\n Vector(-0.7, 3, 1.2)\n }\n }\n\n -- stateIDs for the multi-stated resource tokens\n local stateTable = {\n [\"resource\"] = 1,\n [\"ammo\"] = 2,\n [\"bounty\"] = 3,\n [\"charge\"] = 4,\n [\"evidence\"] = 5,\n [\"secret\"] = 6,\n [\"supply\"] = 7,\n [\"offering\"] = 8\n }\n\n -- Table of data extracted from the token source bag, keyed by the Memo on each token which\n -- should match the token type keys (\"resource\", \"clue\", etc)\n local tokenTemplates\n\n local playerCardData\n local locationData\n\n local TokenManager = {}\n local internal = {}\n\n -- Spawns tokens for the card. This function is built to just throw a card at it and let it do\n -- the work once a card has hit an area where it might spawn tokens. It will check to see if\n -- the card has already spawned, find appropriate data from either the uses metadata or the Data\n -- Helper, and spawn the tokens.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n TokenManager.spawnForCard = function(card, extraUses)\n if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then\n return\n end\n local metadata = JSON.decode(card.getGMNotes())\n if metadata ~= nil then\n internal.spawnTokensFromUses(card, extraUses)\n else\n internal.spawnTokensFromDataHelper(card)\n end\n end\n\n -- Spawns a set of tokens on the given card.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string Type of token to spawn, for example \"damage\", \"horror\" or \"resource\"\n ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the\n -- spawned state object rather than spawning multiple tokens\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)\n local optionPanel = optionPanelApi.getOptions()\n\n if tokenType == \"damage\" or tokenType == \"horror\" then\n TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"enabled\" then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n elseif tokenType == \"resource\" and optionPanel[\"useResourceCounters\"] == \"custom\" and tokenCount == 0 then\n TokenManager.spawnResourceCounterToken(card, tokenCount)\n else\n TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)\n end\n end\n\n -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror tokens.\n ---@param card tts__Object Card to spawn tokens on\n ---@param tokenType string type of token to spawn, valid values are \"damage\" and \"horror\". Other\n -- types should use spawnMultipleTokens()\n ---@param tokenValue number Value to set the damage/horror to\n TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)\n if tokenValue \u003c 1 or tokenValue \u003e 50 then return end\n\n local pos = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[1][1] + Vector(0, 0, shiftDown))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, tokenType, rot, function(spawned)\n -- token starts in state 1, so don't attempt to change it to avoid error\n if tokenValue ~= 1 then\n spawned.setState(tokenValue)\n end\n end)\n end\n\n TokenManager.spawnResourceCounterToken = function(card, tokenCount)\n local pos = card.positionToWorld(card.positionToLocal(card.getPosition()) + Vector(0, 0.2, -0.5))\n local rot = card.getRotation()\n TokenManager.spawnToken(pos, \"resourceCounter\", rot, function(spawned)\n spawned.call(\"updateVal\", tokenCount)\n end)\n end\n\n -- Spawns a number of tokens.\n ---@param tokenType string type of token to spawn, valid values are resource\", \"doom\", or \"clue\".\n -- Other types should use spawnCounterToken()\n ---@param tokenCount number How many tokens to spawn\n ---@param shiftDown? number An offset for the z-value of this group of tokens\n ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens\n TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)\n -- not checking the max at this point since clue offsets are calculated dynamically\n if tokenCount \u003c 1 then return end\n\n local offsets = {}\n if tokenType == \"clue\" then\n offsets = internal.buildClueOffsets(card, tokenCount)\n else\n -- only up to 12 offset tables defined\n if tokenCount \u003e 12 then return end\n for i = 1, tokenCount do\n offsets[i] = card.positionToWorld(PLAYER_CARD_TOKEN_OFFSETS[tokenCount][i])\n -- Fix the y-position for the spawn, since positionToWorld considers rotation which can\n -- have bad results for face up/down differences\n offsets[i].y = card.getPosition().y + 0.15\n end\n end\n\n if shiftDown ~= nil then\n -- Copy the offsets to make sure we don't change the static values\n local baseOffsets = offsets\n offsets = {}\n\n -- get a vector for the shifting (downwards local to the card)\n local shiftDownVector = Vector(0, 0, shiftDown):rotateOver(\"y\", card.getRotation().y)\n for i, baseOffset in ipairs(baseOffsets) do\n offsets[i] = baseOffset + shiftDownVector\n end\n end\n\n if offsets == nil then\n error(\"couldn't find offsets for \" .. tokenCount .. ' tokens')\n return\n end\n\n -- handling for not provided subtype (for example when spawning from custom data helpers)\n if subType == nil then\n subType = \"\"\n end\n\n -- this is used to load the correct state for additional resource tokens (e.g. \"Ammo\")\n local callback = nil\n local stateID = stateTable[string.lower(subType)]\n if tokenType == \"resource\" and stateID ~= nil and stateID ~= 1 then\n callback = function(spawned) spawned.setState(stateID) end\n end\n\n for i = 1, tokenCount do\n TokenManager.spawnToken(offsets[i], tokenType, card.getRotation(), callback)\n end\n end\n\n -- Spawns a single token at the given global position by copying it from the template bag.\n ---@param position tts__Vector Global position to spawn the token\n ---@param tokenType string type of token to spawn, valid values are \"damage\", \"horror\",\n -- \"resource\", \"doom\", or \"clue\"\n ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,\n -- x and z will use the default rotation from the source bag\n ---@param callback? function A callback function triggered after the new token is spawned\n TokenManager.spawnToken = function(position, tokenType, rotation, callback)\n internal.initTokenTemplates()\n local loadTokenType = tokenType\n if tokenType == \"clue\" or tokenType == \"doom\" then\n loadTokenType = \"clueDoom\"\n end\n if tokenTemplates[loadTokenType] == nil then\n error(\"Unknown token type '\" .. tokenType .. \"'\")\n return\n end\n local tokenTemplate = tokenTemplates[loadTokenType]\n\n -- Take ONLY the Y-value for rotation, so we don't flip the token coming out of the bag\n local rot = Vector(tokenTemplate.Transform.rotX, 270, tokenTemplate.Transform.rotZ)\n if rotation ~= nil then\n rot.y = rotation.y\n end\n if tokenType == \"doom\" then\n rot.z = 180\n end\n\n tokenTemplate.Nickname = \"\"\n return spawnObjectData({\n data = tokenTemplate,\n position = position,\n rotation = rot,\n callback_function = callback\n })\n end\n\n -- Checks a card for metadata to maybe replenish it\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n TokenManager.maybeReplenishCard = function(card, uses, mat)\n -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)\n if uses[1].count and uses[1].replenish then\n internal.replenishTokens(card, uses, mat)\n end\n end\n\n -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some\n -- callers.\n ---@param card tts__Object Card object to reset the tokens for\n TokenManager.resetTokensSpawned = function(card)\n tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())\n end\n\n -- Pushes new player card data into the local copy of the Data Helper player data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addPlayerCardData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n playerCardData[k] = v\n end\n end\n\n -- Pushes new location data into the local copy of the Data Helper location data.\n ---@param dataTable table Key/Value pairs following the DataHelper style\n TokenManager.addLocationData = function(dataTable)\n internal.initDataHelperData()\n for k, v in pairs(dataTable) do\n locationData[k] = v\n end\n end\n\n -- Checks to see if the given card has location data in the DataHelper\n ---@param card tts__Object Card to check for data\n ---@return boolean: True if this card has data in the helper, false otherwise\n TokenManager.hasLocationData = function(card)\n internal.initDataHelperData()\n return internal.getLocationData(card) ~= nil\n end\n\n internal.initTokenTemplates = function()\n if tokenTemplates ~= nil then\n return\n end\n tokenTemplates = {}\n local tokenSource = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSource\")\n for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do\n local tokenName = tokenTemplate.Memo\n tokenTemplates[tokenName] = tokenTemplate\n end\n end\n\n -- Copies the data from the DataHelper. Will only happen once.\n internal.initDataHelperData = function()\n if playerCardData ~= nil then\n return\n end\n local dataHelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')\n locationData = dataHelper.getTable('LOCATIONS_DATA')\n end\n\n -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param extraUses table A table of \u003cuse type\u003e=\u003ccount\u003e which will modify the number of tokens\n --- spawned for that type. e.g. Akachi's playmat should pass \"Charge\"=1\n internal.spawnTokensFromUses = function(card, extraUses)\n local uses = internal.getUses(card)\n if uses == nil then return end\n\n -- go through tokens to spawn\n local tokenCount\n for i, useInfo in ipairs(uses) do\n tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()\n if extraUses ~= nil and extraUses[useInfo.type] ~= nil then\n tokenCount = tokenCount + extraUses[useInfo.type]\n end\n -- Shift each spawned group after the first down so they don't pile on each other\n TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type)\n end\n\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state\n -- of the card for both locations and standard cards.\n ---@param card tts__Object Card to maybe spawn tokens for\n internal.spawnTokensFromDataHelper = function(card)\n internal.initDataHelperData()\n local playerData = internal.getPlayerCardData(card)\n if playerData ~= nil then\n internal.spawnPlayerCardTokensFromDataHelper(card, playerData)\n end\n local locationData = internal.getLocationData(card)\n if locationData ~= nil then\n internal.spawnLocationTokensFromDataHelper(card, locationData)\n end\n end\n\n -- Spawn tokens for a player card using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param playerData table Player card data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)\n local token = playerData.tokenType\n local tokenCount = playerData.tokenCount\n TokenManager.spawnTokenGroup(card, token, tokenCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n\n -- Spawn tokens for a location using data retrieved from the Data Helper.\n ---@param card tts__Object Card to maybe spawn tokens for\n ---@param locationData table Location data structure retrieved from the DataHelper. Should be\n -- the right data for this card.\n internal.spawnLocationTokensFromDataHelper = function(card, locationData)\n local clueCount = internal.getClueCountFromData(card, locationData)\n if clueCount \u003e 0 then\n TokenManager.spawnTokenGroup(card, \"clue\", clueCount)\n tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())\n end\n end\n\n internal.getPlayerCardData = function(card)\n return playerCardData[card.getName() .. ':' .. card.getDescription()]\n or playerCardData[card.getName()]\n end\n\n internal.getLocationData = function(card)\n return locationData[card.getName() .. '_' .. card.getGUID()] or locationData[card.getName()]\n end\n\n internal.getClueCountFromData = function(card, locationData)\n -- Return the number of clues to spawn on this location\n if locationData == nil then\n error('attempted to get clue for unexpected object: ' .. card.getName())\n return 0\n end\n\n if ((card.is_face_down and locationData.clueSide == 'back')\n or (not card.is_face_down and locationData.clueSide == 'front')) then\n if locationData.type == 'fixed' then\n return locationData.value\n elseif locationData.type == 'perPlayer' then\n return locationData.value * playAreaApi.getInvestigatorCount()\n end\n error('unexpected location type: ' .. locationData.type)\n end\n return 0\n end\n\n -- Gets the right uses structure for this card, based on metadata and face up/down state\n ---@param card tts__Object Card to pull the uses from\n internal.getUses = function(card)\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.type == \"Location\" then\n if card.is_face_down and metadata.locationBack ~= nil then\n return metadata.locationBack.uses\n elseif not card.is_face_down and metadata.locationFront ~= nil then\n return metadata.locationFront.uses\n end\n elseif not card.is_face_down then\n return metadata.uses\n end\n\n return nil\n end\n\n -- Dynamically create positions for clues on a card.\n ---@param card tts__Object Card the clues will be placed on\n ---@param count number How many clues?\n ---@return table: Array of global positions to spawn the clues at\n internal.buildClueOffsets = function(card, count)\n local cluePositions = {}\n for i = 1, count do\n local row = math.floor(1 + (i - 1) / 4)\n local column = (i - 1) % 4\n local cluePos = card.positionToWorld(Vector(-0.825 + 0.55 * column, 0, -1.5 + 0.55 * row))\n cluePos.y = cluePos.y + 0.05\n table.insert(cluePositions, cluePos)\n end\n return cluePositions\n end\n\n ---@param card tts__Object Card object to be replenished\n ---@param uses table The already decoded metadata.uses (to avoid decoding again)\n ---@param mat tts__Object The playmat the card is placed on (for rotation and casting)\n internal.replenishTokens = function(card, uses, mat)\n local cardPos = card.getPosition()\n\n -- don't continue for cards on the deck (Norman) or in the discard pile\n if mat.positionToLocal(cardPos).x \u003c -1 then return end\n\n -- get current amount of resource tokens on the card\n local clickableResourceCounter = nil\n local foundTokens = 0\n\n for _, obj in ipairs(searchLib.onObject(card, \"isTileOrToken\")) do\n local memo = obj.getMemo()\n\n if (stateTable[memo] or 0) \u003e 0 then\n foundTokens = foundTokens + math.abs(obj.getQuantity())\n obj.destruct()\n elseif memo == \"resourceCounter\" then\n foundTokens = obj.getVar(\"val\")\n clickableResourceCounter = obj\n break\n end\n end\n\n -- this is the theoretical new amount of uses (to be checked below)\n local newCount = foundTokens + uses[1].replenish\n\n -- if there are already more uses than the replenish amount, keep them\n if foundTokens \u003e uses[1].count then\n newCount = foundTokens\n -- only replenish up until the replenish amount\n elseif newCount \u003e uses[1].count then\n newCount = uses[1].count\n end\n\n -- update the clickable counter or spawn a group of tokens\n if clickableResourceCounter then\n clickableResourceCounter.call(\"updateVal\", newCount)\n else\n TokenManager.spawnTokenGroup(card, uses[1].token, newCount, _, uses[1].type)\n end\n end\n\n return TokenManager\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -149621,7 +149939,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ShortSupply\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/cards/ShortSupply\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nfunction onLoad()\n self.addContextMenuItem(\"Discard 10 cards\", shortSupply)\nend\n\n-- called by context menu entry\nfunction shortSupply(color)\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n\n -- get draw deck and discard position\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n local drawDeck = deckAreaObjects.draw\n local discardPos = playmatApi.getDiscardPosition(matColor)\n\n -- error handling\n if discardPos == nil then\n broadcastToColor(\"Couldn't retrieve discard position from playermat!\", color, \"Red\")\n return\n end\n\n if drawDeck == nil then\n broadcastToColor(\"Deck not found!\", color, \"Yellow\")\n return\n elseif drawDeck.type ~= \"Deck\" then\n broadcastToColor(\"Deck only contains a single card!\", color, \"Yellow\")\n return\n end\n\n -- discard cards, waiting 0.7 seconds between each discard to give players visiblity of the cards\n broadcastToColor(\"Discarding top 10 cards for player color '\" .. matColor .. \"'.\", color, \"White\")\n for i = 1, 10 do\n Wait.time(function() drawDeck.takeObject({ flip = true, position = { discardPos.x, 2 + 0.075 * i, discardPos.z } }) end, .7 * (i - 1))\n end\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ShortSupply\")\nend)\n__bundle_register(\"playercards/cards/ShortSupply\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nfunction onLoad()\n self.addContextMenuItem(\"Discard 10 cards\", shortSupply)\nend\n\n-- called by context menu entry\nfunction shortSupply(color)\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n\n -- get draw deck and discard position\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n local drawDeck = deckAreaObjects.draw\n local discardPos = playmatApi.getDiscardPosition(matColor)\n\n -- error handling\n if discardPos == nil then\n broadcastToColor(\"Couldn't retrieve discard position from playermat!\", color, \"Red\")\n return\n end\n\n if drawDeck == nil then\n broadcastToColor(\"Deck not found!\", color, \"Yellow\")\n return\n elseif drawDeck.type ~= \"Deck\" then\n broadcastToColor(\"Deck only contains a single card!\", color, \"Yellow\")\n return\n end\n\n -- discard cards, waiting 0.7 seconds between each discard to give players visiblity of the cards\n broadcastToColor(\"Discarding top 10 cards for player color '\" .. matColor .. \"'.\", color, \"White\")\n for i = 1, 10 do\n Wait.time(function() drawDeck.takeObject({ flip = true, position = { discardPos.x, 2 + 0.075 * i, discardPos.z } }) end, .7 * (i - 1))\n end\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -150055,7 +150373,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/cards/NkosiMabati3\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- XML background color for each token\nlocal tokenColor = {\n [\"Skull\"] = \"#4A0400E6\",\n [\"Cultist\"] = \"#173B0BE6\",\n [\"Tablet\"] = \"#1D2238E6\",\n [\"Elder Thing\"] = \"#4D2331E6\",\n [\"Auto-fail\"] = \"#9B0004E6\",\n [\"Bless\"] = \"#9D702CE6\",\n [\"Curse\"] = \"#633A84E6\",\n [\"Frost\"] = \"#404450E6\",\n [\"\"] = \"#77674DE6\"\n}\n\nlocal sigil\n\nfunction onSave()\n return JSON.encode(sigil)\nend\n\nfunction onLoad(savedData)\n self.addContextMenuItem(\"Enable Helper\", chooseSigil)\n sigil = JSON.decode(savedData)\n if sigil and sigil ~= nil then\n makeXMLButton()\n self.clearContextMenu()\n self.addContextMenuItem(\"Clear Helper\", deleteButtons)\n end\nend\n\nfunction makeXMLButton()\n -- get name of the icon for the sigil (\"token\" + lowercase name without space characters)\n local sigilName = Global.call(\"getReadableTokenName\", sigil)\n local iconName = \"token-\" .. string.lower(sigilName)\n iconName = iconName:gsub(\"%s\", \"-\")\n\n self.UI.setXmlTable({\n {\n tag = \"Button\",\n attributes = {\n height = 450,\n width = 1400,\n rotation = \"0 0 180\",\n scale = \"0.1 0.1 1\",\n position = \"0 -55 -22\",\n padding = \"50 50 50 50\",\n font = \"font_teutonic-arkham\",\n fontSize = 300,\n iconWidth = \"400\",\n iconAlignment = \"Right\",\n onClick = \"resolveSigil\",\n id = sigil,\n icon = iconName,\n color = tokenColor[sigil],\n textColor = \"White\"\n },\n value = \"Resolve\"\n }\n }\n )\nend\n\n-- Create dialog window to choose sigil and create sigil-drawing button\nfunction chooseSigil(playerColor)\n self.clearContextMenu()\n self.addContextMenuItem(\"Clear Helper\", deleteButtons)\n\n -- get list of readable names\n local readableNames = {}\n for token, _ in pairs(tokenColor) do\n table.insert(readableNames, Global.call(\"getReadableTokenName\", token))\n end\n\n -- prompt player to choose sigil\n Player[playerColor].showOptionsDialog(\"Choose Sigil\", readableNames, 1,\n function(chosenToken)\n sigil = Global.call(\"getChaosTokenName\", chosenToken)\n makeXMLButton()\n end\n )\nend\n\n-- Delete button and remove sigil\nfunction deleteButtons()\n self.clearContextMenu()\n self.addContextMenuItem(\"Enable Helper\", chooseSigil)\n self.UI.setXml(\"\")\n sigil = nil\nend\n\nfunction resolveSigil()\n local tokensInPlay = chaosBagApi.getTokensInPlay()\n local chaosbag = chaosBagApi.findChaosBag()\n\n local match = false\n for _, obj in ipairs(chaosbag.getObjects()) do\n -- if there are any sigils in the bag\n if obj.nickname == sigil then\n match = true\n break\n end\n end\n\n if not match then\n broadcastToAll(Global.call(\"getReadableTokenName\", sigil) .. \" not found in chaos bag\", \"Red\")\n return\n end\n\n local matchingSymbolsInPlay = {}\n\n for _, token in ipairs(tokensInPlay) do\n if (token.getName() == \"Cultist\"\n or token.getName() == \"Tablet\"\n or token.getName() == \"Elder Thing\")\n and token.getName() ~= sigil then\n matchingSymbolsInPlay[#matchingSymbolsInPlay + 1] = token\n end\n end\n\n if #matchingSymbolsInPlay == 0 then\n broadcastToAll(\"No eligible symbol token found in play area\", \"Red\")\n return\n elseif #matchingSymbolsInPlay \u003e 1 then\n for _, token in ipairs(matchingSymbolsInPlay) do\n -- draw XML to return token to bag\n token.UI.setXmlTable({\n {\n tag = \"VerticalLayout\",\n attributes = {\n height = 275,\n width = 275,\n spacing = 0,\n padding = \"0 0 20 25\",\n scale = \"0.4 0.4 1\",\n rotation = \"0 0 180\",\n position = \"0 0 -15\",\n color = \"rgba(0,0,0,0.7)\",\n onClick = self.getGUID() .. \"/drawSigil(\" .. token.getGUID() .. \")\"\n },\n children = {\n {\n tag = \"Text\",\n attributes = {\n fontSize = \"100\",\n font = \"font_teutonic-arkham\",\n color = \"#ffffff\",\n text = \"Nkosi\"\n }\n },\n {\n tag = \"Text\",\n attributes = {\n fontSize = \"125\",\n font = \"font_arkhamicons\",\n color = \"#ffffff\",\n text = \"u\"\n }\n }\n }\n }\n })\n end\n else\n drawSigil(_, matchingSymbolsInPlay[1].getGUID())\n end\nend\n\nfunction drawSigil(player, tokenGUID)\n local returnedToken = getObjectFromGUID(tokenGUID)\n local matColor = playmatApi.getMatColorByPosition(returnedToken.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\")\n chaosBagApi.drawChaosToken(mat, true, sigil, _, returnedToken)\n\n -- remove XML from tokens in play\n for _, token in ipairs(chaosBagApi.getTokensInPlay()) do\n if token.getName() == \"Cultist\"\n or token.getName() == \"Tablet\"\n or token.getName() == \"Elder Thing\" then\n token.UI.setXml(\"\")\n end\n end\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/NkosiMabati3\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -151404,7 +151722,7 @@ }, "Description": "Basic Weakness", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"08132\",\n \"type\": \"Treachery\",\n \"class\": \"Neutral\",\n \"traits\": \"Madness.\",\n \"weakness\": true,\n \"basicWeaknessCount\": 1,\n \"cycle\": \"Edge of the Earth\"\n}", + "GMNotes": "{\n \"id\": \"08132\",\n \"type\": \"Treachery\",\n \"class\": \"Neutral\",\n \"traits\": \"Madness.\",\n \"weakness\": true,\n \"basicWeaknessCount\": 1,\n \"uses\": [\n {\n \"count\": 1,\n \"type\": \"Horror\",\n \"token\": \"horror\"\n }\n ],\n \"cycle\": \"Edge of the Earth\"\n}", "GUID": "93e52d", "Grid": true, "GridProjection": false, @@ -151465,7 +151783,7 @@ }, "Description": "Basic Weakness", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"08133\",\n \"type\": \"Treachery\",\n \"class\": \"Neutral\",\n \"traits\": \"Madness.\",\n \"weakness\": true,\n \"basicWeaknessCount\": 1,\n \"cycle\": \"Edge of the Earth\"\n}", + "GMNotes": "{\n \"id\": \"08133\",\n \"type\": \"Treachery\",\n \"class\": \"Neutral\",\n \"traits\": \"Madness.\",\n \"weakness\": true,\n \"basicWeaknessCount\": 1,\n \"uses\": [\n {\n \"count\": 1,\n \"type\": \"Horror\",\n \"token\": \"horror\"\n }\n ],\n \"cycle\": \"Edge of the Earth\"\n}", "GUID": "a42bcf", "Grid": true, "GridProjection": false, @@ -151588,7 +151906,7 @@ }, "Description": "Basic Weakness", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"08131\",\n \"type\": \"Treachery\",\n \"class\": \"Neutral\",\n \"traits\": \"Injury.\",\n \"weakness\": true,\n \"basicWeaknessCount\": 1,\n \"cycle\": \"Edge of the Earth\"\n}", + "GMNotes": "{\n \"id\": \"08131\",\n \"type\": \"Treachery\",\n \"class\": \"Neutral\",\n \"traits\": \"Injury.\",\n \"weakness\": true,\n \"basicWeaknessCount\": 1,\n \"uses\": [\n {\n \"count\": 1,\n \"type\": \"Damage\",\n \"token\": \"damage\"\n }\n ],\n \"cycle\": \"Edge of the Earth\"\n}", "GUID": "46b4a0", "Grid": true, "GridProjection": false, @@ -151773,7 +152091,7 @@ }, "Description": "Basic Weakness", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"08130\",\n \"type\": \"Treachery\",\n \"class\": \"Neutral\",\n \"traits\": \"Injury.\",\n \"weakness\": true,\n \"basicWeaknessCount\": 1,\n \"cycle\": \"Edge of the Earth\"\n}", + "GMNotes": "{\n \"id\": \"08130\",\n \"type\": \"Treachery\",\n \"class\": \"Neutral\",\n \"traits\": \"Injury.\",\n \"weakness\": true,\n \"basicWeaknessCount\": 1,\n \"uses\": [\n {\n \"count\": 1,\n \"type\": \"Damage\",\n \"token\": \"damage\"\n }\n ],\n \"cycle\": \"Edge of the Earth\"\n}", "GUID": "8f1420", "Grid": true, "GridProjection": false, @@ -161997,7 +162315,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/Tekeli-li\")\nend)\n__bundle_register(\"playercards/cards/Tekeli-li\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal deckLib = require(\"util/DeckLib\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nfunction onLoad()\n self.addContextMenuItem(\"Return this card\", returnSelf)\n self.addContextMenuItem(\"Place below my deck\", placeBelowDeck)\nend\n\n-- uses the tekeli-li helper to place this card at the bottom of the deck\nfunction returnSelf()\n local helper = getTekeliliHelper()\n if helper == nil then\n printToAll(\"Couldn't find Tekeli-li Helper!\")\n else\n helper.call(\"returnObject\", self)\n end\nend\n\n-- places this card below the deck of the player that triggered it\nfunction placeBelowDeck(playerColor)\n local matColor = playmatApi.getMatColor(playerColor)\n local deckPos = playmatApi.getDrawPosition(matColor)\n local deckRot = playmatApi.returnRotation(matColor)\n deckRot = deckRot:setAt(\"z\", 180)\n deckLib.placeOrMergeIntoDeck(self, Vector(deckPos), deckRot, true)\nend\n\n-- used to detect the \"Tekeli-li Helper\" for Edge of the Earth\nfunction getTekeliliHelper()\n for _, obj in ipairs(getObjects()) do\n if obj.getName() == \"Tekeli-li Helper\" then\n return obj\n end\n end\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot? table New rotation for the object\n ---@param below? boolean Should the object be placed below an existing deck?\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot, below)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local offset = 0.5\n local newPos = Vector(pos) + Vector(0, offset, 0)\n\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n if below then\n newPos = Vector(pos):setAt(\"y\", bounds.center.y - bounds.size.y / 2)\n else\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n end\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -162058,7 +162376,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/cards/Tekeli-li\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal deckLib = require(\"util/DeckLib\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nfunction onLoad()\n self.addContextMenuItem(\"Return this card\", returnSelf)\n self.addContextMenuItem(\"Place below my deck\", placeBelowDeck)\nend\n\n-- uses the tekeli-li helper to place this card at the bottom of the deck\nfunction returnSelf()\n local helper = getTekeliliHelper()\n if helper == nil then\n printToAll(\"Couldn't find Tekeli-li Helper!\")\n else\n helper.call(\"returnObject\", self)\n end\nend\n\n-- places this card below the deck of the player that triggered it\nfunction placeBelowDeck(playerColor)\n local matColor = playmatApi.getMatColor(playerColor)\n local deckPos = playmatApi.getDrawPosition(matColor)\n local deckRot = playmatApi.returnRotation(matColor)\n deckRot = deckRot:setAt(\"z\", 180)\n deckLib.placeOrMergeIntoDeck(self, Vector(deckPos), deckRot, true)\nend\n\n-- used to detect the \"Tekeli-li Helper\" for Edge of the Earth\nfunction getTekeliliHelper()\n for _, obj in ipairs(getObjects()) do\n if obj.getName() == \"Tekeli-li Helper\" then\n return obj\n end\n end\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot? table New rotation for the object\n ---@param below? boolean Should the object be placed below an existing deck?\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot, below)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local offset = 0.5\n local newPos = Vector(pos) + Vector(0, offset, 0)\n\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n if below then\n newPos = Vector(pos):setAt(\"y\", bounds.center.y - bounds.size.y / 2)\n else\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n end\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/Tekeli-li\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -162119,7 +162437,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/Tekeli-li\")\nend)\n__bundle_register(\"playercards/cards/Tekeli-li\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal deckLib = require(\"util/DeckLib\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nfunction onLoad()\n self.addContextMenuItem(\"Return this card\", returnSelf)\n self.addContextMenuItem(\"Place below my deck\", placeBelowDeck)\nend\n\n-- uses the tekeli-li helper to place this card at the bottom of the deck\nfunction returnSelf()\n local helper = getTekeliliHelper()\n if helper == nil then\n printToAll(\"Couldn't find Tekeli-li Helper!\")\n else\n helper.call(\"returnObject\", self)\n end\nend\n\n-- places this card below the deck of the player that triggered it\nfunction placeBelowDeck(playerColor)\n local matColor = playmatApi.getMatColor(playerColor)\n local deckPos = playmatApi.getDrawPosition(matColor)\n local deckRot = playmatApi.returnRotation(matColor)\n deckRot = deckRot:setAt(\"z\", 180)\n deckLib.placeOrMergeIntoDeck(self, Vector(deckPos), deckRot, true)\nend\n\n-- used to detect the \"Tekeli-li Helper\" for Edge of the Earth\nfunction getTekeliliHelper()\n for _, obj in ipairs(getObjects()) do\n if obj.getName() == \"Tekeli-li Helper\" then\n return obj\n end\n end\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot? table New rotation for the object\n ---@param below? boolean Should the object be placed below an existing deck?\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot, below)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local offset = 0.5\n local newPos = Vector(pos) + Vector(0, offset, 0)\n\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n if below then\n newPos = Vector(pos):setAt(\"y\", bounds.center.y - bounds.size.y / 2)\n else\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n end\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -162180,7 +162498,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/Tekeli-li\")\nend)\n__bundle_register(\"playercards/cards/Tekeli-li\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal deckLib = require(\"util/DeckLib\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nfunction onLoad()\n self.addContextMenuItem(\"Return this card\", returnSelf)\n self.addContextMenuItem(\"Place below my deck\", placeBelowDeck)\nend\n\n-- uses the tekeli-li helper to place this card at the bottom of the deck\nfunction returnSelf()\n local helper = getTekeliliHelper()\n if helper == nil then\n printToAll(\"Couldn't find Tekeli-li Helper!\")\n else\n helper.call(\"returnObject\", self)\n end\nend\n\n-- places this card below the deck of the player that triggered it\nfunction placeBelowDeck(playerColor)\n local matColor = playmatApi.getMatColor(playerColor)\n local deckPos = playmatApi.getDrawPosition(matColor)\n local deckRot = playmatApi.returnRotation(matColor)\n deckRot = deckRot:setAt(\"z\", 180)\n deckLib.placeOrMergeIntoDeck(self, Vector(deckPos), deckRot, true)\nend\n\n-- used to detect the \"Tekeli-li Helper\" for Edge of the Earth\nfunction getTekeliliHelper()\n for _, obj in ipairs(getObjects()) do\n if obj.getName() == \"Tekeli-li Helper\" then\n return obj\n end\n end\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot? table New rotation for the object\n ---@param below? boolean Should the object be placed below an existing deck?\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot, below)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local offset = 0.5\n local newPos = Vector(pos) + Vector(0, offset, 0)\n\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n if below then\n newPos = Vector(pos):setAt(\"y\", bounds.center.y - bounds.size.y / 2)\n else\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n end\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -162241,7 +162559,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/Tekeli-li\")\nend)\n__bundle_register(\"playercards/cards/Tekeli-li\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal deckLib = require(\"util/DeckLib\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nfunction onLoad()\n self.addContextMenuItem(\"Return this card\", returnSelf)\n self.addContextMenuItem(\"Place below my deck\", placeBelowDeck)\nend\n\n-- uses the tekeli-li helper to place this card at the bottom of the deck\nfunction returnSelf()\n local helper = getTekeliliHelper()\n if helper == nil then\n printToAll(\"Couldn't find Tekeli-li Helper!\")\n else\n helper.call(\"returnObject\", self)\n end\nend\n\n-- places this card below the deck of the player that triggered it\nfunction placeBelowDeck(playerColor)\n local matColor = playmatApi.getMatColor(playerColor)\n local deckPos = playmatApi.getDrawPosition(matColor)\n local deckRot = playmatApi.returnRotation(matColor)\n deckRot = deckRot:setAt(\"z\", 180)\n deckLib.placeOrMergeIntoDeck(self, Vector(deckPos), deckRot, true)\nend\n\n-- used to detect the \"Tekeli-li Helper\" for Edge of the Earth\nfunction getTekeliliHelper()\n for _, obj in ipairs(getObjects()) do\n if obj.getName() == \"Tekeli-li Helper\" then\n return obj\n end\n end\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot? table New rotation for the object\n ---@param below? boolean Should the object be placed below an existing deck?\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot, below)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local offset = 0.5\n local newPos = Vector(pos) + Vector(0, offset, 0)\n\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n if below then\n newPos = Vector(pos):setAt(\"y\", bounds.center.y - bounds.size.y / 2)\n else\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n end\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -162302,7 +162620,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/Tekeli-li\")\nend)\n__bundle_register(\"playercards/cards/Tekeli-li\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal deckLib = require(\"util/DeckLib\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nfunction onLoad()\n self.addContextMenuItem(\"Return this card\", returnSelf)\n self.addContextMenuItem(\"Place below my deck\", placeBelowDeck)\nend\n\n-- uses the tekeli-li helper to place this card at the bottom of the deck\nfunction returnSelf()\n local helper = getTekeliliHelper()\n if helper == nil then\n printToAll(\"Couldn't find Tekeli-li Helper!\")\n else\n helper.call(\"returnObject\", self)\n end\nend\n\n-- places this card below the deck of the player that triggered it\nfunction placeBelowDeck(playerColor)\n local matColor = playmatApi.getMatColor(playerColor)\n local deckPos = playmatApi.getDrawPosition(matColor)\n local deckRot = playmatApi.returnRotation(matColor)\n deckRot = deckRot:setAt(\"z\", 180)\n deckLib.placeOrMergeIntoDeck(self, Vector(deckPos), deckRot, true)\nend\n\n-- used to detect the \"Tekeli-li Helper\" for Edge of the Earth\nfunction getTekeliliHelper()\n for _, obj in ipairs(getObjects()) do\n if obj.getName() == \"Tekeli-li Helper\" then\n return obj\n end\n end\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot? table New rotation for the object\n ---@param below? boolean Should the object be placed below an existing deck?\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot, below)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local offset = 0.5\n local newPos = Vector(pos) + Vector(0, offset, 0)\n\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n if below then\n newPos = Vector(pos):setAt(\"y\", bounds.center.y - bounds.size.y / 2)\n else\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n end\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -162363,7 +162681,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/Tekeli-li\")\nend)\n__bundle_register(\"playercards/cards/Tekeli-li\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal deckLib = require(\"util/DeckLib\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nfunction onLoad()\n self.addContextMenuItem(\"Return this card\", returnSelf)\n self.addContextMenuItem(\"Place below my deck\", placeBelowDeck)\nend\n\n-- uses the tekeli-li helper to place this card at the bottom of the deck\nfunction returnSelf()\n local helper = getTekeliliHelper()\n if helper == nil then\n printToAll(\"Couldn't find Tekeli-li Helper!\")\n else\n helper.call(\"returnObject\", self)\n end\nend\n\n-- places this card below the deck of the player that triggered it\nfunction placeBelowDeck(playerColor)\n local matColor = playmatApi.getMatColor(playerColor)\n local deckPos = playmatApi.getDrawPosition(matColor)\n local deckRot = playmatApi.returnRotation(matColor)\n deckRot = deckRot:setAt(\"z\", 180)\n deckLib.placeOrMergeIntoDeck(self, Vector(deckPos), deckRot, true)\nend\n\n-- used to detect the \"Tekeli-li Helper\" for Edge of the Earth\nfunction getTekeliliHelper()\n for _, obj in ipairs(getObjects()) do\n if obj.getName() == \"Tekeli-li Helper\" then\n return obj\n end\n end\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/DeckLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckLib = {}\n local searchLib = require(\"util/SearchLib\")\n\n -- places a card/deck at a position or merges into an existing deck\n ---@param obj tts__Object Object to move\n ---@param pos table New position for the object\n ---@param rot? table New rotation for the object\n ---@param below? boolean Should the object be placed below an existing deck?\n DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot, below)\n if obj == nil or pos == nil then return end\n\n -- search the new position for existing card/deck\n local searchResult = searchLib.atPosition(pos, \"isCardOrDeck\")\n\n -- get new position\n local offset = 0.5\n local newPos = Vector(pos) + Vector(0, offset, 0)\n\n if #searchResult == 1 then\n local bounds = searchResult[1].getBounds()\n if below then\n newPos = Vector(pos):setAt(\"y\", bounds.center.y - bounds.size.y / 2)\n else\n newPos = Vector(pos):setAt(\"y\", bounds.center.y + bounds.size.y / 2 + offset)\n end\n end\n\n -- allow moving the objects smoothly out of the hand\n obj.use_hands = false\n\n if rot then\n obj.setRotationSmooth(rot, false, true)\n end\n obj.setPositionSmooth(newPos, false, true)\n\n -- continue if the card stops smooth moving\n Wait.condition(\n function()\n obj.use_hands = true\n -- this avoids a TTS bug that merges unrelated cards that are not resting\n if #searchResult == 1 and searchResult[1] ~= obj then\n -- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)\n pcall(function() searchResult[1].putObject(obj) end)\n end\n end,\n function() return not obj.isSmoothMoving() end, 3)\n end\n\n return DeckLib\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -162415,7 +162733,7 @@ }, "Description": "Weakness.", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"08646\",\n \"type\": \"Treachery\",\n \"class\": \"Neutral\",\n \"traits\": \"Injury.\",\n \"weakness\": true,\n \"cycle\": \"Edge of the Earth\"\n}", + "GMNotes": "{\n \"id\": \"08646\",\n \"type\": \"Treachery\",\n \"class\": \"Neutral\",\n \"traits\": \"Injury.\",\n \"weakness\": true,\n \"uses\": [\n {\n \"count\": 1,\n \"type\": \"Damage\",\n \"token\": \"damage\"\n }\n ],\n \"cycle\": \"Edge of the Earth\"\n}", "GUID": "8abd77", "Grid": true, "GridProjection": false, @@ -162476,7 +162794,7 @@ }, "Description": "Weakness.", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"08647\",\n \"type\": \"Treachery\",\n \"class\": \"Neutral\",\n \"traits\": \"Madness.\",\n \"weakness\": true,\n \"cycle\": \"Edge of the Earth\"\n}", + "GMNotes": "{\n \"id\": \"08647\",\n \"type\": \"Treachery\",\n \"class\": \"Neutral\",\n \"traits\": \"Madness.\",\n \"weakness\": true,\n \"uses\": [\n {\n \"count\": 1,\n \"type\": \"Horror\",\n \"token\": \"horror\"\n }\n ],\n \"cycle\": \"Edge of the Earth\"\n}", "GUID": "04b3a9", "Grid": true, "GridProjection": false, @@ -171645,7 +171963,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"09022\",\n \"type\": \"Asset\",\n \"slot\": \"Hand x2\",\n \"class\": \"Guardian\",\n \"cost\": 4,\n \"level\": 0,\n \"traits\": \"Item. Weapon. Melee.\",\n \"combatIcons\": 1,\n \"uses\": [\n {\n \"count\": 4,\n \"replenish\": 1,\n \"type\": \"Charge\",\n \"token\": \"resource\"\n }\n ],\n \"customizations\": [\n {\n \"name\": \"Heirloom\",\n \"xp\": 1,\n \"text\": \"This asset gets -1 cost and gains the Relic trait.\",\n \"replaces\": {\n \"cost\": 3,\n \"traits\": \"Item. Relic. Weapon. Melee.\"\n }\n },\n {\n \"name\": \"Inscription of Glory\",\n \"xp\": 1,\n \"text\": \"Add this inscription: “⟐ Glory - If this attack defeats an enemy, choose one: draw 1 card, heal 1 damage, or heal 1 horror.”\"\n },\n {\n \"name\": \"Inscription of the Elders\",\n \"xp\": 1,\n \"text\": \"Add this inscription: “⟐ Elders - If this attack succeeds by an amount equal to or grather than your location\\u0027s shroud, discover 1 clue at your location.”\"\n },\n {\n \"name\": \"Inscription of the Hunt\",\n \"xp\": 1,\n \"text\": \"Add this inscription: “⟐ Hunt - Immediately move to a connecting location or engage an enemy at your location.”\"\n },\n {\n \"name\": \"Inscription of Fury\",\n \"xp\": 1,\n \"text\": \"Add this inscription: “⟐ Fury - If this attack is successful, in addition to its standard damage, deal 1 damage to each other enemy engaged with you.”\"\n },\n {\n \"name\": \"Ancient Power\",\n \"xp\": 3,\n \"text\": \"You may imbue the same inscription up to three times.\"\n },\n {\n \"name\": \"Saga\",\n \"xp\": 3,\n \"text\": \"Replenish 2 of Runic Axe\\u0027s charges at the start of each round, instead of only one\",\n \"replaces\": {\n \"uses\": [\n {\n \"count\": 4,\n \"replenish\": 2,\n \"type\": \"Charge\",\n \"token\": \"resource\"\n }\n ]\n }\n },\n {\n \"name\": \"Scriptweaver\",\n \"xp\": 4,\n \"text\": \"For every charge spent, you may imbue the axe with up to two different inscriptions.\"\n }\n ],\n \"cycle\": \"The Scarlet Keys\"\n}", + "GMNotes": "{\n \"id\": \"09022\",\n \"type\": \"Asset\",\n \"slot\": \"Hand x2\",\n \"class\": \"Guardian\",\n \"cost\": 4,\n \"level\": 0,\n \"traits\": \"Item. Weapon. Melee.\",\n \"combatIcons\": 1,\n \"uses\": [\n {\n \"count\": 4,\n \"replenish\": 1,\n \"type\": \"Charge\",\n \"token\": \"resource\"\n }\n ],\n \"customizations\": [\n {\n \"name\": \"Heirloom\",\n \"xp\": 1,\n \"text\": \"This asset gets -1 cost and gains the Relic trait.\",\n \"replaces\": {\n \"cost\": 3,\n \"traits\": \"Item. Relic. Weapon. Melee.\"\n }\n },\n {\n \"name\": \"Inscription of Glory\",\n \"xp\": 1,\n \"text\": \"Add this inscription: “⟐ Glory - If this attack defeats an enemy, choose one: draw 1 card, heal 1 damage, or heal 1 horror.”\"\n },\n {\n \"name\": \"Inscription of the Elders\",\n \"xp\": 1,\n \"text\": \"Add this inscription: “⟐ Elders - If this attack succeeds by an amount equal to or grather than your location's shroud, discover 1 clue at your location.”\"\n },\n {\n \"name\": \"Inscription of the Hunt\",\n \"xp\": 1,\n \"text\": \"Add this inscription: “⟐ Hunt - Immediately move to a connecting location or engage an enemy at your location.”\"\n },\n {\n \"name\": \"Inscription of Fury\",\n \"xp\": 1,\n \"text\": \"Add this inscription: “⟐ Fury - If this attack is successful, in addition to its standard damage, deal 1 damage to each other enemy engaged with you.”\"\n },\n {\n \"name\": \"Ancient Power\",\n \"xp\": 3,\n \"text\": \"You may imbue the same inscription up to three times.\"\n },\n {\n \"name\": \"Saga\",\n \"xp\": 3,\n \"text\": \"Replenish 2 of Runic Axe's charges at the start of each round, instead of only one\",\n \"replaces\": {\n \"uses\": [\n {\n \"count\": 4,\n \"replenish\": 2,\n \"type\": \"Charge\",\n \"token\": \"resource\"\n }\n ]\n }\n },\n {\n \"name\": \"Scriptweaver\",\n \"xp\": 4,\n \"text\": \"For every charge spent, you may imbue the axe with up to two different inscriptions.\"\n }\n ],\n \"cycle\": \"The Scarlet Keys\"\n}", "GUID": "7cdb0a", "Grid": true, "GridProjection": false, @@ -172505,7 +172823,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"09123\",\n \"type\": \"Asset\",\n \"class\": \"Neutral\",\n \"level\": 3,\n \"traits\": \"Ritual.\",\n \"permanent\": true,\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Offering\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Scarlet Keys\"\n}", + "GMNotes": "{\n \"id\": \"09123\",\n \"type\": \"Asset\",\n \"class\": \"Neutral\",\n \"startsInPlay\": true,\n \"level\": 3,\n \"traits\": \"Ritual.\",\n \"permanent\": true,\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Offering\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Scarlet Keys\"\n}", "GUID": "52f6d6", "Grid": true, "GridProjection": false, @@ -176319,7 +176637,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"09061\",\n \"type\": \"Event\",\n \"class\": \"Rogue\",\n \"cost\": 1,\n \"level\": 0,\n \"traits\": \"Gambit.\",\n \"agilityIcons\": 1,\n \"customizations\": [\n {\n \"name\": \"Reflex Response\",\n \"xp\": 1,\n \"text\": \"Add the following play condition: “\\u003d You take damage or horror.”\"\n },\n {\n \"name\": \"Situational Awareness\",\n \"xp\": 1,\n \"text\": \"Add the following play condition: “\\u003d A location enters play or is revealed.”\"\n },\n {\n \"name\": \"Killer Instinct\",\n \"xp\": 1,\n \"text\": \"Add the following play condition: “\\u003d An enemy engages you.”\"\n },\n {\n \"name\": \"Gut Reaction\",\n \"xp\": 1,\n \"text\": \"Add the following play condition: “\\u003d A treachery enters your threat area .”\"\n },\n {\n \"name\": \"Muscle Memory\",\n \"xp\": 1,\n \"text\": \"Add the following play condition: “\\u003d You play an asset.”\"\n },\n {\n \"name\": \"Sharpened Talent\",\n \"xp\": 2,\n \"text\": \"During the action granted by Honed Instinct, you get +2 to each of your skills.\"\n },\n {\n \"name\": \"Impulse Control\",\n \"xp\": 3,\n \"text\": \"You may include up to three copies of Honed Instinct in your deck. Honed Instinct gets –1 cost.\",\n \"replaces\": {\n \"cost\": 0\n }\n },\n {\n \"name\": \"Force of Habit\",\n \"xp\": 5,\n \"text\": \"When you play Honed Instinct, you may take 2 actions instead of 1 (one at a time). Then, remove it from the game.\"\n }\n ],\n \"cycle\": \"The Scarlet Keys\"\n}", + "GMNotes": "{\n \"id\": \"09061\",\n \"type\": \"Event\",\n \"class\": \"Rogue\",\n \"cost\": 1,\n \"level\": 0,\n \"traits\": \"Gambit.\",\n \"agilityIcons\": 1,\n \"customizations\": [\n {\n \"name\": \"Reflex Response\",\n \"xp\": 1,\n \"text\": \"Add the following play condition: “- You take damage or horror.”\"\n },\n {\n \"name\": \"Situational Awareness\",\n \"xp\": 1,\n \"text\": \"Add the following play condition: “- A location enters play or is revealed.”\"\n },\n {\n \"name\": \"Killer Instinct\",\n \"xp\": 1,\n \"text\": \"Add the following play condition: “- An enemy engages you.”\"\n },\n {\n \"name\": \"Gut Reaction\",\n \"xp\": 1,\n \"text\": \"Add the following play condition: “- A treachery enters your threat area .”\"\n },\n {\n \"name\": \"Muscle Memory\",\n \"xp\": 1,\n \"text\": \"Add the following play condition: “- You play an asset.”\"\n },\n {\n \"name\": \"Sharpened Talent\",\n \"xp\": 2,\n \"text\": \"During the action granted by Honed Instinct, you get +2 to each of your skills.\"\n },\n {\n \"name\": \"Impulse Control\",\n \"xp\": 3,\n \"text\": \"You may include up to three copies of Honed Instinct in your deck. Honed Instinct gets –1 cost.\",\n \"replaces\": {\n \"cost\": 0\n }\n },\n {\n \"name\": \"Force of Habit\",\n \"xp\": 5,\n \"text\": \"When you play Honed Instinct, you may take 2 actions instead of 1 (one at a time). Then, remove it from the game.\"\n }\n ],\n \"cycle\": \"The Scarlet Keys\"\n}", "GUID": "1cde62", "Grid": true, "GridProjection": false, @@ -177559,7 +177877,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/EmpiricalHypothesis\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/cards/EmpiricalHypothesis\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this helper creates buttons to help the user track which hypothesis has been chosen each round\n-- (if user forgot to choose one at round start, the old one stays active)\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal upgradeSheetLibrary = require(\"playercards/customizable/UpgradeSheetLibrary\")\n\n-- common button parameters\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.height = 160\nbuttonParameters.width = 1000\nbuttonParameters.font_size = 84\nbuttonParameters.font_color = { 1.0, 1.0, 1.0 }\nbuttonParameters.color = Color.Black\nbuttonParameters.position = {}\nbuttonParameters.position.x = 0\nbuttonParameters.position.y = 0.6\nbuttonParameters.position.z = -1.05\ninitialButtonPosition = buttonParameters.position.z\n\n-- vertical offset between buttons\nlocal verticalOffset = 0.325\n\n-- list of customizable labels\nlocal customizableList = {\n 'Run out of cards in hand',\n 'Take damage/horror',\n 'Discard treachery/enemy',\n 'Enter 3 or more shroud'\n}\n\n-- index of the currently selected button (0-indexed from the top)\nlocal activeButtonIndex\n\nfunction onSave()\n return JSON.encode(activeButtonIndex)\nend\n\nfunction onLoad(savedData)\n self.addContextMenuItem(\"Enable Helper\", createButtons)\n self.addContextMenuItem(\"Clear Helper\", deleteButtons)\n\n activeButtonIndex = JSON.decode(savedData)\n if activeButtonIndex and activeButtonIndex ~= \"\" then\n local tempButtonIndex = activeButtonIndex\n createButtons()\n if tempButtonIndex \u003e= 0 then\n selectButton(tempButtonIndex)\n end\n end\nend\n\n-- marks a button as active\n---@param index number Index of the button to mark (starts at 0 from the top)\nfunction selectButton(index)\n local lastindex = #hypothesisList - 1\n for i = 0, lastindex do\n local color = Color.Black\n if i == index then\n color = Color.Red\n activeButtonIndex = i\n end\n self.editButton({ index = i, color = color })\n end\nend\n\nfunction deleteButtons()\n self.clearButtons()\n self.clearContextMenu()\n self.addContextMenuItem(\"Enable Helper\", createButtons)\n buttonParameters.position.z = initialButtonPosition -- reset the z position\nend\n\n-- Create buttons based on the button parameters\nfunction createButtons()\n self.clearContextMenu()\n self.addContextMenuItem(\"Clear Helper\", deleteButtons)\n\n -- reset the list in case of addition of checkboxes or Refine\n hypothesisList = {\n 'Succeed by 3 or more',\n 'Fail by 2 or more'\n }\n\n -- set activeButtonIndex to restore state onLoad (\"-1\" -\u003e nothing selected)\n activeButtonIndex = -1\n\n -- get the upgradesheet and check for more conditions\n local upgradeSheet = findUpgradeSheet()\n if upgradeSheet then\n for i = 1, 4 do\n if upgradeSheet.call(\"isUpgradeActive\", i) then\n table.insert(hypothesisList, customizableList[i])\n end\n end\n end\n\n for i, label in ipairs(hypothesisList) do\n buttonParameters.click_function = \"selectButton\" .. i\n self.setVar(buttonParameters.click_function, function() selectButton(i - 1) end)\n buttonParameters.label = label\n self.createButton(buttonParameters)\n buttonParameters.position.z = buttonParameters.position.z + verticalOffset\n end\nend\n\nfunction findUpgradeSheet()\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n local result = playmatApi.searchAroundPlaymat(matColor, \"isCard\")\n for j, card in ipairs(result) do\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.id == \"09041-c\" then\n return card\n end\n end\nend\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/EmpiricalHypothesis\")\nend)\n__bundle_register(\"playercards/cards/EmpiricalHypothesis\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this helper creates buttons to help the user track which hypothesis has been chosen each round\n-- (if user forgot to choose one at round start, the old one stays active)\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal upgradeSheetLibrary = require(\"playercards/customizable/UpgradeSheetLibrary\")\n\n-- common button parameters\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.height = 160\nbuttonParameters.width = 1000\nbuttonParameters.font_size = 84\nbuttonParameters.font_color = { 1.0, 1.0, 1.0 }\nbuttonParameters.color = Color.Black\nbuttonParameters.position = {}\nbuttonParameters.position.x = 0\nbuttonParameters.position.y = 0.6\nbuttonParameters.position.z = -1.05\ninitialButtonPosition = buttonParameters.position.z\n\n-- vertical offset between buttons\nlocal verticalOffset = 0.325\n\n-- list of customizable labels\nlocal customizableList = {\n 'Run out of cards in hand',\n 'Take damage/horror',\n 'Discard treachery/enemy',\n 'Enter 3 or more shroud'\n}\n\n-- index of the currently selected button (0-indexed from the top)\nlocal activeButtonIndex\n\nfunction onSave()\n return JSON.encode(activeButtonIndex)\nend\n\nfunction onLoad(savedData)\n self.addContextMenuItem(\"Enable Helper\", createButtons)\n self.addContextMenuItem(\"Clear Helper\", deleteButtons)\n\n activeButtonIndex = JSON.decode(savedData)\n if activeButtonIndex and activeButtonIndex ~= \"\" then\n local tempButtonIndex = activeButtonIndex\n createButtons()\n if tempButtonIndex \u003e= 0 then\n selectButton(tempButtonIndex)\n end\n end\nend\n\n-- marks a button as active\n---@param index number Index of the button to mark (starts at 0 from the top)\nfunction selectButton(index)\n local lastindex = #hypothesisList - 1\n for i = 0, lastindex do\n local color = Color.Black\n if i == index then\n color = Color.Red\n activeButtonIndex = i\n end\n self.editButton({ index = i, color = color })\n end\nend\n\nfunction deleteButtons()\n self.clearButtons()\n self.clearContextMenu()\n self.addContextMenuItem(\"Enable Helper\", createButtons)\n buttonParameters.position.z = initialButtonPosition -- reset the z position\nend\n\n-- Create buttons based on the button parameters\nfunction createButtons()\n self.clearContextMenu()\n self.addContextMenuItem(\"Clear Helper\", deleteButtons)\n\n -- reset the list in case of addition of checkboxes or Refine\n hypothesisList = {\n 'Succeed by 3 or more',\n 'Fail by 2 or more'\n }\n\n -- set activeButtonIndex to restore state onLoad (\"-1\" -\u003e nothing selected)\n activeButtonIndex = -1\n\n -- get the upgradesheet and check for more conditions\n local upgradeSheet = findUpgradeSheet()\n if upgradeSheet then\n for i = 1, 4 do\n if upgradeSheet.call(\"isUpgradeActive\", i) then\n table.insert(hypothesisList, customizableList[i])\n end\n end\n end\n\n for i, label in ipairs(hypothesisList) do\n buttonParameters.click_function = \"selectButton\" .. i\n self.setVar(buttonParameters.click_function, function() selectButton(i - 1) end)\n buttonParameters.label = label\n self.createButton(buttonParameters)\n buttonParameters.position.z = buttonParameters.position.z + verticalOffset\n end\nend\n\nfunction findUpgradeSheet()\n local matColor = playmatApi.getMatColorByPosition(self.getPosition())\n local result = playmatApi.searchAroundPlaymat(matColor, \"isCard\")\n for j, card in ipairs(result) do\n local metadata = JSON.decode(card.getGMNotes()) or {}\n if metadata.id == \"09041-c\" then\n return card\n end\n end\nend\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -178604,7 +178922,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/SummonedServitorUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/SummonedServitorUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Summoned Servitor\n\n-- Color information for buttons\nboxSize = 35\n\n-- static values\nxInitial = -0.935\nxOffset = 0.068\n\n-- Locations of the slot selectors\nSLOT_ICON_POSITIONS = {\n arcane = { x = 0.160, z = 0.65 },\n ally = { x = -0.073, z = 0.65 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nSLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n--selectedSlot = SLOT_INDICES.none\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.92,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.625,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.33,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = 0.055,\n count = 1,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.26,\n count = 1,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.56,\n count = 2,\n }\n -- Row 6 includes the selection of Arcane/Ally slot, presented with buttons but stored\n -- as a text field\n },\n [7] = {\n checkboxes = {\n posZ = 0.765,\n count = 3,\n },\n },\n [8] = {\n checkboxes = {\n posZ = 1.06,\n count = 5,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/SummonedServitorUpgradeSheet\")\nend)\n__bundle_register(\"playercards/customizable/SummonedServitorUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Summoned Servitor\n\n-- Color information for buttons\nboxSize = 35\n\n-- static values\nxInitial = -0.935\nxOffset = 0.068\n\n-- Locations of the slot selectors\nSLOT_ICON_POSITIONS = {\n arcane = { x = 0.160, z = 0.65 },\n ally = { x = -0.073, z = 0.65 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nSLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n--selectedSlot = SLOT_INDICES.none\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.92,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.625,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.33,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = 0.055,\n count = 1,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.26,\n count = 1,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.56,\n count = 2,\n }\n -- Row 6 includes the selection of Arcane/Ally slot, presented with buttons but stored\n -- as a text field\n },\n [7] = {\n checkboxes = {\n posZ = 0.765,\n count = 3,\n },\n },\n [8] = {\n checkboxes = {\n posZ = 1.06,\n count = 5,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\"]]", "MeasureMovement": false, "Name": "CardCustom", @@ -178665,7 +178983,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/RunicAxeUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/RunicAxeUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Runic Axe\n\n-- Color information for buttons\nboxSize = 38\n\n-- static values\nxInitial = -0.935\nxOffset = 0.0705\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.92,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.715,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.415,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.018,\n count = 1,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.265,\n count = 1,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.66,\n count = 3,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.86,\n count = 3,\n },\n },\n [8] = {\n checkboxes = {\n posZ = 1.065,\n count = 4,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/RunicAxeUpgradeSheet\")\nend)\n__bundle_register(\"playercards/customizable/RunicAxeUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Runic Axe\n\n-- Color information for buttons\nboxSize = 38\n\n-- static values\nxInitial = -0.935\nxOffset = 0.0705\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.92,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.715,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.415,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.018,\n count = 1,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.265,\n count = 1,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.66,\n count = 3,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.86,\n count = 3,\n },\n },\n [8] = {\n checkboxes = {\n posZ = 1.065,\n count = 4,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "CardCustom", @@ -178726,7 +179044,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/PowerWordUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/PowerWordUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Power Word\n\n-- Color information for buttons\nboxSize = 38\n\n-- static values\nxInitial = -0.933\nxOffset = 0.069\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.905,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.6,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.32,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.02,\n count = 1,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.28,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.48,\n count = 3,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.775,\n count = 3,\n },\n },\n [8] = {\n checkboxes = {\n posZ = 0.975,\n count = 3,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/PowerWordUpgradeSheet\")\nend)\n__bundle_register(\"playercards/customizable/PowerWordUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Power Word\n\n-- Color information for buttons\nboxSize = 38\n\n-- static values\nxInitial = -0.933\nxOffset = 0.069\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.905,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.6,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.32,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.02,\n count = 1,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.28,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.48,\n count = 3,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.775,\n count = 3,\n },\n },\n [8] = {\n checkboxes = {\n posZ = 0.975,\n count = 3,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "CardCustom", @@ -178787,7 +179105,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/PocketMultiToolUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/PocketMultiToolUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Pocket Multi Tool\n\n-- Color information for buttons\nboxSize = 40\n\n-- static values\nxInitial = -0.933\nxOffset = 0.075\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.892,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.560,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.326,\n count = 2,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.092,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.142,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.376,\n count = 3,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.610,\n count = 4,\n },\n },\n}\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/PocketMultiToolUpgradeSheet\")\nend)\n__bundle_register(\"playercards/customizable/PocketMultiToolUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Pocket Multi Tool\n\n-- Color information for buttons\nboxSize = 40\n\n-- static values\nxInitial = -0.933\nxOffset = 0.075\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.892,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.560,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.326,\n count = 2,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.092,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.142,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.376,\n count = 3,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.610,\n count = 4,\n },\n },\n}\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "CardCustom", @@ -178848,7 +179166,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/MakeshiftTrapUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/MakeshiftTrapUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Makeshift Trap\n\n-- Color information for buttons\nboxSize = 39\n\n-- static values\nxInitial = -0.935\nxOffset = 0.0735\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.889,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.655,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.325,\n count = 2,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.085,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.252,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.585,\n count = 3,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.927,\n count = 4,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/MakeshiftTrapUpgradeSheet\")\nend)\n__bundle_register(\"playercards/customizable/MakeshiftTrapUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Makeshift Trap\n\n-- Color information for buttons\nboxSize = 39\n\n-- static values\nxInitial = -0.935\nxOffset = 0.0735\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.889,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.655,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.325,\n count = 2,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.085,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.252,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.585,\n count = 3,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.927,\n count = 4,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "CardCustom", @@ -178909,7 +179227,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/LivingInkUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/LivingInkUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Living Ink\n\n-- Size information for buttons\nboxSize = 40\n\n-- static values\nxInitial = -0.935\nxOffset = 0.075\n\n-- Locations of the skill selectors\nSKILL_ICON_POSITIONS = {\n willpower = { x = 0.085, z = -0.88 },\n intellect = { x = -0.183, z = -0.88 },\n combat = { x = -0.473, z = -0.88 },\n agility = { x = -0.74, z = -0.88 },\n}\n\ncustomizations = {\n [1] = { }, -- Empty placeholder for skill selection row, handled by custom skill display\n [2] = {\n checkboxes = {\n posZ = -0.69,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.355,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = 0.0855,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.425,\n count = 2,\n }\n },\n [6] = {\n checkboxes = {\n posZ = 0.555,\n count = 3,\n },\n },\n [7] = {\n checkboxes = {\n posZ = 0.685,\n count = 3,\n }\n },\n [8] = {\n checkboxes = {\n posZ = 1.02,\n count = 3,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/LivingInkUpgradeSheet\")\nend)\n__bundle_register(\"playercards/customizable/LivingInkUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Living Ink\n\n-- Size information for buttons\nboxSize = 40\n\n-- static values\nxInitial = -0.935\nxOffset = 0.075\n\n-- Locations of the skill selectors\nSKILL_ICON_POSITIONS = {\n willpower = { x = 0.085, z = -0.88 },\n intellect = { x = -0.183, z = -0.88 },\n combat = { x = -0.473, z = -0.88 },\n agility = { x = -0.74, z = -0.88 },\n}\n\ncustomizations = {\n [1] = { }, -- Empty placeholder for skill selection row, handled by custom skill display\n [2] = {\n checkboxes = {\n posZ = -0.69,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.355,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = 0.0855,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.425,\n count = 2,\n }\n },\n [6] = {\n checkboxes = {\n posZ = 0.555,\n count = 3,\n },\n },\n [7] = {\n checkboxes = {\n posZ = 0.685,\n count = 3,\n }\n },\n [8] = {\n checkboxes = {\n posZ = 1.02,\n count = 3,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[]]", "MeasureMovement": false, "Name": "CardCustom", @@ -178970,7 +179288,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/HyperphysicalShotcasterUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/HyperphysicalShotcasterUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Hyperphysical Shotcaster\n\n-- Color information for buttons\nboxSize = 38\n\n-- static values\nxInitial = -0.935\nxOffset = 0.069\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.9,\n count = 2,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.615,\n count = 2,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.237,\n count = 2,\n }\n },\n [4] = {\n checkboxes = {\n posZ = 0.232,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.61,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.988,\n count = 4,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 1.185,\n count = 4,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/HyperphysicalShotcasterUpgradeSheet\")\nend)\n__bundle_register(\"playercards/customizable/HyperphysicalShotcasterUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Hyperphysical Shotcaster\n\n-- Color information for buttons\nboxSize = 38\n\n-- static values\nxInitial = -0.935\nxOffset = 0.069\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.9,\n count = 2,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.615,\n count = 2,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.237,\n count = 2,\n }\n },\n [4] = {\n checkboxes = {\n posZ = 0.232,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.61,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.988,\n count = 4,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 1.185,\n count = 4,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "CardCustom", @@ -179031,7 +179349,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/HuntersArmorUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/HuntersArmorUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Hunter's Armor\n\n-- Color information for buttons\nboxSize = 40\n\n-- static values\nxInitial = -0.933\nxOffset = 0.075\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.892,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.560,\n count = 2,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.220,\n count = 2,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.092,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.047,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.376,\n count = 3,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.820,\n count = 3,\n },\n },\n}\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/HuntersArmorUpgradeSheet\")\nend)\n__bundle_register(\"playercards/customizable/HuntersArmorUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Hunter's Armor\n\n-- Color information for buttons\nboxSize = 40\n\n-- static values\nxInitial = -0.933\nxOffset = 0.075\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.892,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.560,\n count = 2,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.220,\n count = 2,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.092,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.047,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.376,\n count = 3,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.820,\n count = 3,\n },\n },\n}\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "CardCustom", @@ -179092,7 +179410,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/HonedInstinctUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/HonedInstinctUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Honed Instinct\n\n-- Color information for buttons\nboxSize = 38\n\n-- static values\nxInitial = -0.935\nxOffset = 0.069\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.905,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.705,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.5,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.29,\n count = 1,\n }\n },\n [5] = {\n checkboxes = {\n posZ = -0.09,\n count = 1,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.12,\n count = 2,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.325,\n count = 3,\n },\n },\n [8] = {\n checkboxes = {\n posZ = 0.62,\n count = 5,\n }\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/customizable/HonedInstinctUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Honed Instinct\n\n-- Color information for buttons\nboxSize = 38\n\n-- static values\nxInitial = -0.935\nxOffset = 0.069\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.905,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.705,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.5,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.29,\n count = 1,\n }\n },\n [5] = {\n checkboxes = {\n posZ = -0.09,\n count = 1,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.12,\n count = 2,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.325,\n count = 3,\n },\n },\n [8] = {\n checkboxes = {\n posZ = 0.62,\n count = 5,\n }\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/HonedInstinctUpgradeSheet\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "CardCustom", @@ -179153,7 +179471,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/GrizzledUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/GrizzledUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Grizzled\n\n-- Color information for buttons and input boxes\nboxSize = 40\ninputFontsize = 50\n\n-- static values\nxInitial = -0.933\nxOffset = 0.075\n\ncustomizations = {\n [1] = {\n textField = {\n position = { 0.3, 0.25, -0.91 },\n width = 600\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.71,\n count = 1,\n },\n textField = {\n position = { 0.005, 0.25, -0.58 },\n width = 875\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.458,\n count = 2,\n },\n textField = {\n position = { 0.005, 0.25, -0.32 },\n width = 875\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.205,\n count = 3,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.362,\n count = 4,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.82,\n count = 5,\n },\n },\n}\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/GrizzledUpgradeSheet\")\nend)\n__bundle_register(\"playercards/customizable/GrizzledUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Grizzled\n\n-- Color information for buttons and input boxes\nboxSize = 40\ninputFontsize = 50\n\n-- static values\nxInitial = -0.933\nxOffset = 0.075\n\ncustomizations = {\n [1] = {\n textField = {\n position = { 0.3, 0.25, -0.91 },\n width = 600\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.71,\n count = 1,\n },\n textField = {\n position = { 0.005, 0.25, -0.58 },\n width = 875\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.458,\n count = 2,\n },\n textField = {\n position = { 0.005, 0.25, -0.32 },\n width = 875\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.205,\n count = 3,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.362,\n count = 4,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.82,\n count = 5,\n },\n },\n}\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "CardCustom", @@ -179214,7 +179532,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/FriendsinLowPlacesUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/FriendsinLowPlacesUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Friends in Low Places\n\n-- Color information for buttons and input boxes\nboxSize = 36\ninputFontsize = 50\n\n-- static values\nxInitial = -0.935\nxOffset = 0.0685\n\ncustomizations = {\n [1] = {\n textField = {\n position = { 0.275, 0.25, -0.91 },\n width = 640\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.725,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.44,\n count = 2,\n },\n textField = {\n position = { 0.6295, 0.25, -0.44 },\n width = 290\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.05,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.25,\n count = 2,\n }\n },\n [6] = {\n checkboxes = {\n posZ = 0.545,\n count = 2,\n },\n },\n [7] = {\n checkboxes = {\n posZ = 0.75,\n count = 3,\n }\n },\n [8] = {\n checkboxes = {\n posZ = 0.95,\n count = 3,\n }\n },\n}\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/FriendsinLowPlacesUpgradeSheet\")\nend)\n__bundle_register(\"playercards/customizable/FriendsinLowPlacesUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Friends in Low Places\n\n-- Color information for buttons and input boxes\nboxSize = 36\ninputFontsize = 50\n\n-- static values\nxInitial = -0.935\nxOffset = 0.0685\n\ncustomizations = {\n [1] = {\n textField = {\n position = { 0.275, 0.25, -0.91 },\n width = 640\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.725,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.44,\n count = 2,\n },\n textField = {\n position = { 0.6295, 0.25, -0.44 },\n width = 290\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.05,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.25,\n count = 2,\n }\n },\n [6] = {\n checkboxes = {\n posZ = 0.545,\n count = 2,\n },\n },\n [7] = {\n checkboxes = {\n posZ = 0.75,\n count = 3,\n }\n },\n [8] = {\n checkboxes = {\n posZ = 0.95,\n count = 3,\n }\n },\n}\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "CardCustom", @@ -179275,7 +179593,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/EmpiricalHypothesisUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/EmpiricalHypothesisUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Empirical Hypothesis\n\n-- Color information for buttons\nboxSize = 37\n\n-- static values\nxInitial = -0.935\nxOffset = 0.069\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.905,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.7,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.505,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.3,\n count = 1,\n }\n },\n [5] = {\n checkboxes = {\n posZ = -0.09,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.3,\n count = 2,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.592,\n count = 3,\n },\n },\n [8] = {\n checkboxes = {\n posZ = 0.888,\n count = 4,\n }\n },\n}\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/EmpiricalHypothesisUpgradeSheet\")\nend)\n__bundle_register(\"playercards/customizable/EmpiricalHypothesisUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Empirical Hypothesis\n\n-- Color information for buttons\nboxSize = 37\n\n-- static values\nxInitial = -0.935\nxOffset = 0.069\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.905,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.7,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.505,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.3,\n count = 1,\n }\n },\n [5] = {\n checkboxes = {\n posZ = -0.09,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.3,\n count = 2,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.592,\n count = 3,\n },\n },\n [8] = {\n checkboxes = {\n posZ = 0.888,\n count = 4,\n }\n },\n}\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "CardCustom", @@ -179336,7 +179654,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/DamningTestimonyUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/DamningTestimonyUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Damning Testimony\n\n-- Color information for buttons\nboxSize = 40\n\n-- static values\nxInitial = -0.935\nxOffset = 0.075\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.925,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.475,\n count = 2,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.25,\n count = 2,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.01,\n count = 3,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.428,\n count = 3,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.772,\n count = 4,\n }\n },\n}\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/customizable/DamningTestimonyUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Damning Testimony\n\n-- Color information for buttons\nboxSize = 40\n\n-- static values\nxInitial = -0.935\nxOffset = 0.075\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.925,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.475,\n count = 2,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.25,\n count = 2,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.01,\n count = 3,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.428,\n count = 3,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.772,\n count = 4,\n }\n },\n}\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/DamningTestimonyUpgradeSheet\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "CardCustom", @@ -179397,7 +179715,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/CustomModificationsUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/CustomModificationsUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Custom Modifications\n\n-- Color information for buttons\nboxSize = 38\n\n-- static values\nxInitial = -0.935\nxOffset = 0.0735\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.895,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.455,\n count = 2,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.215,\n count = 2,\n }\n },\n [4] = {\n checkboxes = {\n posZ = 0.115,\n count = 3,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.453,\n count = 3,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.794,\n count = 4,\n }\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/CustomModificationsUpgradeSheet\")\nend)\n__bundle_register(\"playercards/customizable/CustomModificationsUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Custom Modifications\n\n-- Color information for buttons\nboxSize = 38\n\n-- static values\nxInitial = -0.935\nxOffset = 0.0735\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.895,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.455,\n count = 2,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.215,\n count = 2,\n }\n },\n [4] = {\n checkboxes = {\n posZ = 0.115,\n count = 3,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.453,\n count = 3,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.794,\n count = 4,\n }\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "CardCustom", @@ -179458,7 +179776,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/AlchemicalDistillationUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/AlchemicalDistillationUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Alchemical Distillation\n\n-- Color information for buttons\nboxSize = 40\n\n-- static values\nxInitial = -0.933\nxOffset = 0.075\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.892,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.665,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.43,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.092,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.142,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.376,\n count = 4,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.815,\n count = 5,\n }\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/AlchemicalDistillationUpgradeSheet\")\nend)\n__bundle_register(\"playercards/customizable/AlchemicalDistillationUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Alchemical Distillation\n\n-- Color information for buttons\nboxSize = 40\n\n-- static values\nxInitial = -0.933\nxOffset = 0.075\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.892,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.665,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.43,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.092,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.142,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.376,\n count = 4,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.815,\n count = 5,\n }\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "CardCustom", @@ -180075,7 +180393,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/TheRavenQuillUpgradeSheet\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/TheRavenQuillUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: The Raven Quill\n\n-- Color information for buttons and input boxes\nboxSize = 37\ninputFontsize = 38\n\n-- static values\nxInitial = -0.935\nxOffset = 0.0705\n\ncustomizations = {\n [1] = {\n textField = {\n position = { 0.5, 0.25, -0.905 },\n width = 425\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.72,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.52,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.305,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = -0.105,\n count = 2,\n },\n textField = {\n position = { 0.125, 0.25, 0 },\n width = 775\n }\n },\n [6] = {\n checkboxes = {\n posZ = 0.1,\n count = 2,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.4,\n count = 3,\n }\n },\n [8] = {\n checkboxes = {\n posZ = 0.695,\n count = 4,\n }\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/TheRavenQuillUpgradeSheet\")\nend)\n__bundle_register(\"playercards/customizable/TheRavenQuillUpgradeSheet\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: The Raven Quill\n\n-- Color information for buttons and input boxes\nboxSize = 37\ninputFontsize = 38\n\n-- static values\nxInitial = -0.935\nxOffset = 0.0705\n\ncustomizations = {\n [1] = {\n textField = {\n position = { 0.5, 0.25, -0.905 },\n width = 425\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.72,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.52,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.305,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = -0.105,\n count = 2,\n },\n textField = {\n position = { 0.125, 0.25, 0 },\n width = 775\n }\n },\n [6] = {\n checkboxes = {\n posZ = 0.1,\n count = 2,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.4,\n count = 3,\n }\n },\n [8] = {\n checkboxes = {\n posZ = 0.695,\n count = 4,\n }\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "CardCustom", @@ -183844,21 +184162,21 @@ "z": 0 }, "Autoraise": true, - "CardID": 55100, + "CardID": 14300, "ColorDiffuse": { "b": 0.71324, "g": 0.71324, "r": 0.71324 }, "CustomDeck": { - "551": { + "143": { "BackIsHidden": true, - "BackURL": "http://cloud-3.steamusercontent.com/ugc/2021607899142907490/4AAE686A793E66311FF78890309D20670A329D16/", - "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2021607899142907034/013ED775CA50C6FC71731E4FBAEBF1ECA8C68F1E/", - "NumHeight": 2, - "NumWidth": 2, + "BackURL": "http://cloud-3.steamusercontent.com/ugc/2414565357243142126/51E7BDBC4F3E68487E896E867200B6C9310ADF3D/", + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2414565357243142219/EB53C43AB498B112B5EA2C488F0EB1543CD43DE5/", + "NumHeight": 1, + "NumWidth": 1, "Type": 0, - "UniqueBack": true + "UniqueBack": false } }, "Description": "The Reporter", @@ -183875,7 +184193,7 @@ "LuaScript": "", "LuaScriptState": "", "MeasureMovement": false, - "Name": "Card", + "Name": "CardCustom", "Nickname": "Rex Murphy (Taboo)", "SidewaysCard": true, "Snap": true, @@ -183934,7 +184252,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/RunicAxeUpgradeSheetTaboo\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/RunicAxeUpgradeSheetTaboo\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Runic Axe (Taboo)\n\n-- Color information for buttons\nboxSize = 38\n\n-- static values\nxInitial = -0.935\nxOffset = 0.0705\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.92,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.715,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.415,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.018,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.265,\n count = 1,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.66,\n count = 3,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.86,\n count = 3,\n },\n },\n [8] = {\n checkboxes = {\n posZ = 1.065,\n count = 4,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/RunicAxeUpgradeSheetTaboo\")\nend)\n__bundle_register(\"playercards/customizable/RunicAxeUpgradeSheetTaboo\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Runic Axe (Taboo)\n\n-- Color information for buttons\nboxSize = 38\n\n-- static values\nxInitial = -0.935\nxOffset = 0.0705\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.92,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.715,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.415,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.018,\n count = 2,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.265,\n count = 1,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.66,\n count = 3,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.86,\n count = 3,\n },\n },\n [8] = {\n checkboxes = {\n posZ = 1.065,\n count = 4,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "Card", @@ -183995,7 +184313,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/PowerWordUpgradeSheetTaboo\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/customizable/PowerWordUpgradeSheetTaboo\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Power Word (Taboo)\n\n-- Color information for buttons\nboxSize = 38\n\n-- static values\nxInitial = -0.933\nxOffset = 0.069\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.905,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.6,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.42,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.12,\n count = 1,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.18,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.38,\n count = 3,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.675,\n count = 3,\n },\n },\n [8] = {\n checkboxes = {\n posZ = 0.875,\n count = 3,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/customizable/PowerWordUpgradeSheetTaboo\")\nend)\n__bundle_register(\"playercards/customizable/PowerWordUpgradeSheetTaboo\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Customizable Cards: Power Word (Taboo)\n\n-- Color information for buttons\nboxSize = 38\n\n-- static values\nxInitial = -0.933\nxOffset = 0.069\n\ncustomizations = {\n [1] = {\n checkboxes = {\n posZ = -0.905,\n count = 1,\n }\n },\n [2] = {\n checkboxes = {\n posZ = -0.6,\n count = 1,\n }\n },\n [3] = {\n checkboxes = {\n posZ = -0.42,\n count = 1,\n }\n },\n [4] = {\n checkboxes = {\n posZ = -0.12,\n count = 1,\n }\n },\n [5] = {\n checkboxes = {\n posZ = 0.18,\n count = 2,\n },\n },\n [6] = {\n checkboxes = {\n posZ = 0.38,\n count = 3,\n }\n },\n [7] = {\n checkboxes = {\n posZ = 0.675,\n count = 3,\n },\n },\n [8] = {\n checkboxes = {\n posZ = 0.875,\n count = 3,\n },\n },\n}\n\nrequire(\"playercards/customizable/UpgradeSheetLibrary\")\nend)\n__bundle_register(\"playercards/customizable/UpgradeSheetLibrary\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Common code for handling customizable card upgrade sheets\n-- Define UI elements in the base card file, then include this\n-- UI element definition is an array of tables, each with this structure. A row may include\n-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom\n-- handling, as Living Ink does)\n-- {\n-- checkboxes = {\n-- posZ = -0.71,\n-- count = 1,\n-- },\n-- textField = {\n-- position = { 0.005, 0.25, -0.58 },\n-- width = 875\n-- }\n-- }\n-- Fields should also be defined for xInitial (left edge of the checkboxes) and xOffset (amount to\n-- shift X from one box to the next) as well as boxSize (checkboxes) and inputFontSize.\n--\n-- selectedUpgrades holds the state of checkboxes and text input, each element being:\n-- selectedUpgrades[row] = { xp = #, text = \"\" }\n\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object\n-- when not selected.\nlocal Y_VISIBLE = 0.25\nlocal Y_INVISIBLE = -0.5\n\n-- Used for Summoned Servitor and Living Ink\nlocal VECTOR_COLOR = {\n unselected = { 0.5, 0.5, 0.5, 0.75 },\n mystic = { 0.597, 0.195, 0.796 }\n}\n\n-- These match with ArkhamDB's way of storing the data in the dropdown menu\nlocal SUMMONED_SERVITOR_SLOT_INDICES = { arcane = \"1\", ally = \"0\", none = \"\" }\n\nlocal rowCheckboxFirstIndex = { }\nlocal rowInputIndex = { }\nlocal selectedUpgrades = { }\n\n-- save state when going into bags / decks\nfunction onDestroy() self.script_state = onSave() end\n\nfunction onSave()\n return JSON.encode({\n selections = selectedUpgrades\n })\nend\n\n-- Startup procedure\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n if loadedData.selections ~= nil then\n selectedUpgrades = loadedData.selections\n end\n end\n\n selfId = getSelfId()\n\n maybeLoadLivingInkSkills()\n createUi()\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\n\n self.addContextMenuItem(\"Clear Selections\", function() resetSelections() end)\n self.addContextMenuItem(\"Scale: 1x\", function() self.setScale({ 1, 1, 1 }) end)\n self.addContextMenuItem(\"Scale: 2x\", function() self.setScale({ 2, 1, 2 }) end)\n self.addContextMenuItem(\"Scale: 3x\", function() self.setScale({ 3, 1, 3 }) end)\nend\n\n-- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)\nfunction getSelfId()\n local metadata = JSON.decode(self.getGMNotes())\n return metadata.id\nend\n\nfunction isUpgradeActive(row)\n return customizations[row] ~= nil\n and customizations[row].checkboxes ~= nil\n and customizations[row].checkboxes.count ~= nil\n and customizations[row].checkboxes.count \u003e 0\n and selectedUpgrades[row] ~= nil\n and selectedUpgrades[row].xp ~= nil\n and selectedUpgrades[row].xp \u003e= customizations[row].checkboxes.count\nend\n\nfunction resetSelections()\n selectedUpgrades = { }\n updateDisplay()\nend\n\nfunction createUi()\n if customizations == nil then\n return\n end\n for i = 1, #customizations do\n if customizations[i].checkboxes ~= nil then\n createRowCheckboxes(i)\n end\n if customizations[i].textField ~= nil then\n createRowTextField(i)\n end\n end\n maybeMakeLivingInkSkillSelectionButtons()\n maybeMakeServitorSlotSelectionButtons()\n updateDisplay()\nend\n\nfunction createRowCheckboxes(rowIndex)\n local checkboxes = customizations[rowIndex].checkboxes\n rowCheckboxFirstIndex[rowIndex] = 0\n local previousButtons = self.getButtons()\n if previousButtons ~= nil then\n rowCheckboxFirstIndex[rowIndex] = #previousButtons\n end\n for col = 1, checkboxes.count do\n local funcName = \"checkboxRow\" .. rowIndex .. \"Col\" .. col\n local func = function() clickCheckbox(rowIndex, col) end\n self.setVar(funcName, func)\n local checkboxPos = getCheckboxPosition(rowIndex, col)\n\n self.createButton({\n click_function = funcName,\n function_owner = self,\n position = checkboxPos,\n height = boxSize * 10,\n width = boxSize * 10,\n font_size = 1000,\n scale = { 0.1, 0.1, 0.1 },\n color = { 0, 0, 0 },\n font_color = { 0, 0, 0 }\n })\n end\nend\n\nfunction getCheckboxPosition(row, col)\n return {\n x = xInitial + col * xOffset,\n y = Y_VISIBLE,\n z = customizations[row].checkboxes.posZ\n }\nend\n\nfunction createRowTextField(rowIndex)\n local textField = customizations[rowIndex].textField\n\n rowInputIndex[rowIndex] = 0\n local previousInputs = self.getInputs()\n if previousInputs ~= nil then\n rowInputIndex[rowIndex] = #previousInputs\n end\n local funcName = \"textbox\" .. rowIndex\n local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end\n self.setVar(funcName, func)\n\n self.createInput({\n input_function = funcName,\n function_owner = self,\n label = \"Click to type\",\n alignment = 2,\n position = textField.position,\n scale = { 0.1, 0.1, 0.1 },\n width = textField.width * 10,\n height = inputFontsize * 10 + 75,\n font_size = inputFontsize * 10.5,\n color = \"White\",\n value = \"\"\n })\nend\n\nfunction updateDisplay()\n for i = 1, #customizations do\n updateRowDisplay(i)\n end\n maybeUpdateLivingInkSkillDisplay()\n maybeUpdateServitorSlotDisplay()\nend\n\nfunction updateRowDisplay(rowIndex)\n if customizations[rowIndex].checkboxes ~= nil then\n updateCheckboxes(rowIndex)\n end\n if customizations[rowIndex].textField ~= nil then\n updateTextField(rowIndex)\n end\nend\n\nfunction updateCheckboxes(rowIndex)\n local checkboxCount = customizations[rowIndex].checkboxes.count\n local selected = 0\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then\n selected = selectedUpgrades[rowIndex].xp\n end\n local checkboxIndex = rowCheckboxFirstIndex[rowIndex]\n for col = 1, checkboxCount do\n local pos = getCheckboxPosition(rowIndex, col)\n if col \u003c= selected then\n pos.y = Y_VISIBLE\n else\n pos.y = Y_INVISIBLE\n end\n self.editButton({\n index = checkboxIndex,\n position = pos\n })\n checkboxIndex = checkboxIndex + 1\n end\nend\n\nfunction updateTextField(rowIndex)\n local inputIndex = rowInputIndex[rowIndex]\n if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then\n self.editInput({\n index = inputIndex,\n value = \" \" .. selectedUpgrades[rowIndex].text\n })\n end\nend\n\nfunction clickCheckbox(row, col)\n if selectedUpgrades[row] == nil then\n selectedUpgrades[row] = { }\n selectedUpgrades[row].xp = 0\n end\n if selectedUpgrades[row].xp == col then\n selectedUpgrades[row].xp = col - 1\n else\n selectedUpgrades[row].xp = col\n end\n updateCheckboxes(row)\n playmatApi.syncAllCustomizableCards()\nend\n\n-- Updates saved value for given text box when it loses focus\nfunction clickTextbox(rowIndex, value, selected)\n if selected == false then\n if selectedUpgrades[rowIndex] == nil then\n selectedUpgrades[rowIndex] = { }\n end\n selectedUpgrades[rowIndex].text = value:gsub(\"^%s*(.-)%s*$\", \"%1\")\n -- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished\n Wait.frames(function() updateRowDisplay(rowIndex) end, 1)\n end\nend\n\n---------------------------------------------------------\n-- Living Ink related functions\n---------------------------------------------------------\n\n-- Builds the list of boolean skill selections from the Row 1 text field\nfunction maybeLoadLivingInkSkills()\n if selfId ~= \"09079-c\" then return end\n selectedSkills = {\n willpower = false,\n intellect = false,\n combat = false,\n agility = false\n }\n if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then\n for skill in string.gmatch(selectedUpgrades[1].text, \"([^,]+)\") do\n selectedSkills[skill] = true\n end\n end\nend\n\nfunction clickSkill(skillname)\n selectedSkills[skillname] = not selectedSkills[skillname]\n maybeUpdateLivingInkSkillDisplay()\n updateSelectedLivingInkSkillText()\nend\n\n-- Creates the invisible buttons overlaying the skill icons\nfunction maybeMakeLivingInkSkillSelectionButtons()\n if selfId ~= \"09079-c\" then return end\n\n local buttonData = {\n function_owner = self,\n position = { y = 0.2 },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n\n for skillname, _ in pairs(selectedSkills) do\n local funcName = \"clickSkill\" .. skillname\n self.setVar(funcName, function() clickSkill(skillname) end)\n\n buttonData.click_function = funcName\n buttonData.position.x = -1 * SKILL_ICON_POSITIONS[skillname].x\n buttonData.position.z = SKILL_ICON_POSITIONS[skillname].z\n self.createButton(buttonData)\n end\nend\n\n-- Builds a comma-delimited string of skills and places it in the Row 1 text field\nfunction updateSelectedLivingInkSkillText()\n local skillString = \"\"\n if selectedSkills.willpower then\n skillString = skillString .. \"willpower\" .. \",\"\n end\n if selectedSkills.intellect then\n skillString = skillString .. \"intellect\" .. \",\"\n end\n if selectedSkills.combat then\n skillString = skillString .. \"combat\" .. \",\"\n end\n if selectedSkills.agility then\n skillString = skillString .. \"agility\" .. \",\"\n end\n if selectedUpgrades[1] == nil then\n selectedUpgrades[1] = { }\n end\n selectedUpgrades[1].text = skillString\nend\n\n-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of\n-- vectors set, have to refresh all 4 at once\nfunction maybeUpdateLivingInkSkillDisplay()\n if selfId ~= \"09079-c\" then return end\n local circles = {}\n for skill, isSelected in pairs(selectedSkills) do\n if isSelected then\n local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])\n if circle ~= nil then\n table.insert(circles, circle)\n end\n end\n end\n self.setVectorLines(circles)\nend\n\nfunction getCircleVector(center)\n local diameter = Vector(0, 0, 0.1)\n local pointOfOrigin = Vector(center.x, Y_VISIBLE, center.z)\n local vec\n local vecList = {}\n local arcStep = 5\n for i = 0, 360, arcStep do\n diameter:rotateOver('y', arcStep)\n vec = pointOfOrigin + diameter\n vec.y = pointOfOrigin.y\n table.insert(vecList, vec)\n end\n\n return {\n points = vecList,\n color = VECTOR_COLOR.mystic,\n thickness = 0.02,\n }\nend\n\n---------------------------------------------------------\n-- Summoned Servitor related functions\n---------------------------------------------------------\n\n-- Creates the invisible buttons overlaying the slot words\nfunction maybeMakeServitorSlotSelectionButtons()\n if selfId ~= \"09080-c\" then return end\n\n local buttonData = {\n click_function = \"clickArcane\",\n function_owner = self,\n position = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z },\n height = 130,\n width = 130,\n color = { 0, 0, 0, 0 },\n }\n self.createButton(buttonData)\n\n buttonData.click_function = \"clickAlly\"\n buttonData.position.x = -1 * SLOT_ICON_POSITIONS.ally.x\n self.createButton(buttonData)\nend\n\n-- toggles the clicked slot\nfunction clickArcane()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- toggles the clicked slot\nfunction clickAlly()\n if selectedUpgrades[6] == nil then\n selectedUpgrades[6] = { }\n end\n if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none\n else\n selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally\n end\n maybeUpdateServitorSlotDisplay()\nend\n\n-- Refresh the vector circles indicating a slot is selected.\nfunction maybeUpdateServitorSlotDisplay()\n if selfId ~= \"09080-c\" then return end\n\n local center = SLOT_ICON_POSITIONS[\"arcane\"]\n local arcaneVecList = {\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),\n }\n\n center = SLOT_ICON_POSITIONS[\"ally\"]\n local allyVecList = {\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),\n Vector(center.x - 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z - 0.05),\n Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),\n }\n\n local arcaneVecColor = VECTOR_COLOR.unselected\n local allyVecColor = VECTOR_COLOR.unselected\n\n if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then\n arcaneVecColor = VECTOR_COLOR.mystic\n elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then\n allyVecColor = VECTOR_COLOR.mystic\n end\n\n self.setVectorLines({\n {\n points = arcaneVecList,\n color = arcaneVecColor,\n thickness = 0.02,\n },\n {\n points = allyVecList,\n color = allyVecColor,\n thickness = 0.02,\n }\n })\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", "MeasureMovement": false, "Name": "Card", @@ -185468,7 +185786,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/FluteoftheOuterGods4\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"playercards/cards/FluteoftheOuterGods4\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Curse\"] = true\n}\n\nSHOW_SINGLE_RELEASE = true\nKEEP_OPEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/cards/FluteoftheOuterGods4\", function(require, _LOADED, __bundle_register, __bundle_modules)\nVALID_TOKENS = {\n [\"Curse\"] = true\n}\n\nSHOW_SINGLE_RELEASE = true\nKEEP_OPEN = true\n\nrequire(\"playercards/CardsThatSealTokens\")\nend)\n__bundle_register(\"playercards/CardsThatSealTokens\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Library for cards that seal tokens\nThis file is used to add sealing option to cards' context menu.\nValid options (set before requiring this file):\n\nUPDATE_ON_HOVER --@type: boolean\n - automatically updates the context menu options when the card is hovered\n - the \"Read Bag\" function reads the content of the chaos bag to update the context menu\n - example usage: \"Unrelenting\" (to only display valid tokens)\n\nKEEP_OPEN --@type: boolean\n- meant for cards that seal single tokens multiple times (one by one)\n- makes the context menu stay open after selecting an option\n- example usage: \"Unrelenting\"\n\nSHOW_SINGLE_RELEASE --@type: boolean\n - enables an entry in the context menu\n - this entry allows releasing a single token\n - example usage: \"Holy Spear\" (to keep the other tokens and just release one)\n\nSHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)\n - enables an entry in the context menu\n - this entry allows releasing of multiple tokens at once\n - example usage: \"Nephthys\" (to release 3 bless tokens at once)\n\nSHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)\n - enables an entry in the context menu\n - this entry allows returning tokens to the token pool\n - example usage: \"Nephthys\" (to return 3 bless tokens at once)\n\nSHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)\n - enables an entry in the context menu\n - this entry allows sealing of multiple tokens at once\n - example usage: \"Holy Spear\" (to seal two bless tokens at once)\n\nVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens should be abled to be sealed\n - needs to be defined for each card -\u003e even if empty\n - example usage: \"The Chthonian Stone\"\n \u003e VALID_TOKENS = {\n \u003e [\"Skull\"] = true,\n \u003e [\"Cultist\"] = true,\n \u003e [\"Tablet\"] = true,\n \u003e [\"Elder Thing\"] = true,\n \u003e }\n\nINVALID_TOKENS --@type: table ([tokenName] = true)\n - this table defines which tokens are invalid for sealing\n - only needs to be defined if needed\n - usually combined with empty \"VALID_TOKENS\" table\n - example usage: \"Protective Incantation\" (not allowed to seal Auto-fail)\n\n----------------------------------------------------------\nExample 1: Crystalline Elder Sign\nThis card can only seal the \"+1\" or \"Elder Sign\" token,\nit does not need specific options for multi-sealing or releasing.\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"+1\"] = true,\n \u003e [\"Elder Sign\"] = true\n \u003e }\n \u003e require...\n----------------------------------------------------------\nExample 2: Holy Spear\nThis card features the following abilities (just listing the relevant parts):\n- releasing a single bless token\n- sealing two bless tokens\nThus it should be implemented like this:\n \u003e VALID_TOKENS = {\n \u003e [\"Bless\"] = true\n \u003e }\n \u003e SHOW_SINGLE_RELEASE = true\n \u003e SHOW_MULTI_SEAL = 2\n \u003e require...\n----------------------------------------------------------]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal tokenArrangerApi = require(\"accessories/TokenArrangerApi\")\n\nlocal sealedTokens = {}\nlocal ID_URL_MAP = {}\nlocal tokensInBag = {}\n\nfunction onSave() return JSON.encode(sealedTokens) end\n\nfunction onLoad(savedData)\n sealedTokens = JSON.decode(savedData) or {}\n ID_URL_MAP = chaosBagApi.getIdUrlMap()\n generateContextMenu()\n self.addTag(\"CardThatSeals\")\nend\n\n-- builds the context menu\nfunction generateContextMenu()\n -- conditional single or multi release options\n if SHOW_SINGLE_RELEASE then\n self.addContextMenuItem(\"Release token\", releaseOneToken)\n elseif SHOW_MULTI_RELEASE then\n self.addContextMenuItem(\"Release \" .. SHOW_MULTI_RELEASE .. \" token(s)\", releaseMultipleTokens)\n else\n self.addContextMenuItem(\"Release token(s)\", releaseAllTokens)\n end\n\n if RESOLVE_TOKEN then\n local firstTokenType\n for tokenType, val in pairs(VALID_TOKENS) do\n firstTokenType = tokenType\n break\n end\n self.addContextMenuItem(\"Resolve \" .. firstTokenType, resolveSealed)\n end\n\n -- conditional release option\n if SHOW_MULTI_RETURN then\n self.addContextMenuItem(\"Return \" .. SHOW_MULTI_RETURN .. \" token(s)\", returnMultipleTokens)\n end\n\n -- main context menu options to seal tokens\n for _, map in pairs(ID_URL_MAP) do\n if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then\n if not SHOW_MULTI_SEAL then\n self.addContextMenuItem(\"Seal \" .. map.name, function(playerColor)\n sealToken(map.name, playerColor)\n end, KEEP_OPEN)\n else\n self.addContextMenuItem(\"Seal \" .. SHOW_MULTI_SEAL .. \" \" .. map.name, function(playerColor)\n readBag()\n local allowed = true\n local notFound\n\n for name, _ in pairs(VALID_TOKENS) do\n if (tokensInBag[name] or 0) \u003c SHOW_MULTI_SEAL then\n allowed = false\n notFound = name\n end\n end\n\n if allowed then\n for i = 1, SHOW_MULTI_SEAL do\n sealToken(map.name, playerColor)\n end\n else\n printToColor(\"Not enough \" .. notFound .. \" tokens in the chaos bag.\", playerColor)\n end\n end)\n end\n end\n end\nend\n\n-- generates a list of chaos tokens that is in the chaos bag\nfunction readBag()\n local chaosbag = chaosBagApi.findChaosBag()\n tokensInBag = {}\n\n for _, token in ipairs(chaosbag.getObjects()) do\n tokensInBag[token.name] = (tokensInBag[token.name] or 0) + 1\n end\nend\n\nfunction resetSealedTokens()\n sealedTokens = {}\nend\n\n-- native event from TTS - used to update the context menu for cards like \"Unrelenting\"\nfunction onHover()\n if UPDATE_ON_HOVER then\n readBag()\n self.clearContextMenu()\n generateContextMenu()\n end\nend\n\n-- seals the named token on this card\nfunction sealToken(name, playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n local chaosbag = chaosBagApi.findChaosBag()\n for i, obj in ipairs(chaosbag.getObjects()) do\n if obj.name == name then\n chaosbag.takeObject({\n position = self.getPosition() + Vector(0, 0.5 + 0.1 * #sealedTokens, 0),\n rotation = self.getRotation(),\n index = i - 1,\n smooth = false,\n callback_function = function(token)\n local guid = token.getGUID()\n table.insert(sealedTokens, guid)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.sealedToken(name, guid)\n end\n end\n })\n return\n end\n end\n printToColor(name .. \" token not found in chaos bag\", playerColor)\nend\n\n-- release the last sealed token\nfunction releaseOneToken(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token\", playerColor)\n putTokenAway(table.remove(sealedTokens))\n end\nend\n\n-- release multiple tokens at once\nfunction releaseMultipleTokens(playerColor)\n if SHOW_MULTI_RELEASE \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RELEASE do\n putTokenAway(table.remove(sealedTokens))\n end\n printToColor(\"Releasing \" .. SHOW_MULTI_RELEASE .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- releases all sealed tokens\nfunction releaseAllTokens(playerColor)\n if not chaosBagApi.canTouchChaosTokens() then return end\n if #sealedTokens == 0 then\n printToColor(\"No sealed token(s) found\", playerColor)\n else\n printToColor(\"Releasing token(s)\", playerColor)\n for _, guid in ipairs(sealedTokens) do\n putTokenAway(guid)\n end\n sealedTokens = {}\n end\nend\n\n-- returns multiple tokens at once to the token pool\nfunction returnMultipleTokens(playerColor)\n if SHOW_MULTI_RETURN \u003c= #sealedTokens then\n for i = 1, SHOW_MULTI_RETURN do\n returnToken(table.remove(sealedTokens))\n end\n printToColor(\"Returning \" .. SHOW_MULTI_RETURN .. \" tokens\", playerColor)\n else\n printToColor(\"Not enough tokens sealed.\", playerColor)\n end\nend\n\n-- returns the token (referenced by GUID) to the chaos bag\nfunction putTokenAway(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n local chaosbag = chaosBagApi.findChaosBag()\n chaosbag.putObject(token)\n tokenArrangerApi.layout()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.releasedToken(name, guid)\n end\nend\n\n-- returns the token to the pool (== removes it)\nfunction returnToken(guid)\n local token = getObjectFromGUID(guid)\n if not token then return end\n\n local name = token.getName()\n token.destruct()\n if name == \"Bless\" or name == \"Curse\" then\n blessCurseManagerApi.returnedToken(name, guid)\n end\nend\n\n-- resolves sealed token as if it came from the chaos bag\nfunction resolveSealed()\n if #sealedTokens == 0 then\n broadcastToAll(\"No tokens sealed.\", \"Red\")\n return\n end\n local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())\n local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local guidToBeResolved = table.remove(sealedTokens)\n chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/FluteoftheOuterGods4\")\nend)\n__bundle_register(\"accessories/TokenArrangerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenArrangerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- local function to call the token arranger, if it is on the table\n ---@param functionName string Name of the function to cal\n ---@param argument? table Parameter to pass\n local function callIfExistent(functionName, argument)\n local tokenArranger = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenArranger\")\n if tokenArranger ~= nil then\n tokenArranger.call(functionName, argument)\n end\n end\n\n -- updates the token modifiers with the provided data\n ---@param fullData table Contains the chaos token metadata\n TokenArrangerApi.onTokenDataChanged = function(fullData)\n callIfExistent(\"onTokenDataChanged\", fullData)\n end\n\n -- deletes already laid out tokens\n TokenArrangerApi.deleteCopiedTokens = function()\n callIfExistent(\"deleteCopiedTokens\")\n end\n\n -- updates the laid out tokens\n TokenArrangerApi.layout = function()\n Wait.time(function() callIfExistent(\"layout\") end, 0.1)\n end\n\n return TokenArrangerApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -185775,7 +186093,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ScrollofSecrets\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat\n ---@param mat tts__Object Playermat that triggered this\n ---@param alwaysFaceUp boolean Whether the card should be drawn face-up\n MythosAreaApi.drawEncounterCard = function(mat, alwaysFaceUp)\n getMythosArea().call(\"drawEncounterCard\", {mat = mat, alwaysFaceUp = alwaysFaceUp})\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"playercards/cards/ScrollofSecrets\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between the lvl 0 and lvl 3 versions of Scroll of Secrets\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- get class via metadata and create context menu accordingly\nfunction onLoad()\n local notes = JSON.decode(self.getGMNotes())\n if notes then\n createContextMenu(notes.id)\n else\n print(\"Missing metadata for Scroll of Secrets!\")\n end\nend\n\nfunction createContextMenu(id)\n if id == \"05116\" or id == \"05116-t\" then\n -- lvl 0: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n elseif id == \"05188\" or id == \"05188-t\" then\n -- seeker lvl 3: draw 3 cards from the bottom\n self.addContextMenuItem(\"Draw bottom card(s)\", function(playerColor) contextFunc(playerColor, 3) end)\n elseif id == \"05189\" or id == \"05189-t\" then\n -- mystic lvl 3: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n end\nend\n\nfunction contextFunc(playerColor, amount)\n local options = { \"Encounter Deck\" }\n\n -- check for players with a deck and only display them as option\n for _, color in ipairs(Player.getAvailableColors()) do\n local matColor = playmatApi.getMatColor(color)\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n\n if deckAreaObjects.draw or deckAreaObjects.topCard then\n table.insert(options, color)\n end\n end\n\n -- show the target selection dialog\n Player[playerColor].showOptionsDialog(\"Select target deck\", options, _, function(owner) drawCardsFromBottom(playerColor, owner, amount) end)\nend\n\nfunction drawCardsFromBottom(playerColor, owner, amount)\n -- variable initialization\n local deck = nil\n local deckSize = 1\n local deckAreaObjects = {}\n\n -- get the respective deck\n if owner == \"Encounter Deck\" then\n deck = mythosAreaApi.getEncounterDeck()\n else\n local matColor = playmatApi.getMatColor(owner)\n deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n deck = deckAreaObjects.draw\n end\n\n -- error handling\n if not deck then\n printToColor(\"Couldn't find deck!\", playerColor)\n return\n end\n\n -- set deck size if there is actually a deck and not just a card\n if deck.type == \"Deck\" then\n deckSize = #deck.getObjects()\n end\n\n -- proceed according to deck size\n if deckSize \u003e amount then\n for i = 1, amount do\n local card = deck.takeObject({ top = false, flip = true })\n card.deal(1, playerColor)\n end\n else\n -- deal the whole deck\n deck.deal(amount, playerColor)\n\n if deckSize \u003c amount then\n -- Norman Withers handling\n if deckAreaObjects.topCard then\n deckAreaObjects.topCard.deal(1, playerColor)\n deckSize = deckSize + 1\n end\n\n -- warning message for player\n if deckSize \u003c amount then\n printToColor(\"Deck didn't contain enough cards.\", playerColor)\n end\n end\n end\n printToColor(\"Handle the drawn cards according to the ability text on 'Scroll of Secrets'.\", playerColor)\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ScrollofSecrets\")\nend)\n__bundle_register(\"playercards/cards/ScrollofSecrets\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between the lvl 0 and lvl 3 versions of Scroll of Secrets\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- get class via metadata and create context menu accordingly\nfunction onLoad()\n local notes = JSON.decode(self.getGMNotes())\n if notes then\n createContextMenu(notes.id)\n else\n print(\"Missing metadata for Scroll of Secrets!\")\n end\nend\n\nfunction createContextMenu(id)\n if id == \"05116\" or id == \"05116-t\" then\n -- lvl 0: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n elseif id == \"05188\" or id == \"05188-t\" then\n -- seeker lvl 3: draw 3 cards from the bottom\n self.addContextMenuItem(\"Draw bottom card(s)\", function(playerColor) contextFunc(playerColor, 3) end)\n elseif id == \"05189\" or id == \"05189-t\" then\n -- mystic lvl 3: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n end\nend\n\nfunction contextFunc(playerColor, amount)\n local options = { \"Encounter Deck\" }\n\n -- check for players with a deck and only display them as option\n for _, color in ipairs(Player.getAvailableColors()) do\n local matColor = playmatApi.getMatColor(color)\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n\n if deckAreaObjects.draw or deckAreaObjects.topCard then\n table.insert(options, color)\n end\n end\n\n -- show the target selection dialog\n Player[playerColor].showOptionsDialog(\"Select target deck\", options, _, function(owner) drawCardsFromBottom(playerColor, owner, amount) end)\nend\n\nfunction drawCardsFromBottom(playerColor, owner, amount)\n -- variable initialization\n local deck = nil\n local deckSize = 1\n local deckAreaObjects = {}\n\n -- get the respective deck\n if owner == \"Encounter Deck\" then\n deck = mythosAreaApi.getEncounterDeck()\n else\n local matColor = playmatApi.getMatColor(owner)\n deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n deck = deckAreaObjects.draw\n end\n\n -- error handling\n if not deck then\n printToColor(\"Couldn't find deck!\", playerColor)\n return\n end\n\n -- set deck size if there is actually a deck and not just a card\n if deck.type == \"Deck\" then\n deckSize = #deck.getObjects()\n end\n\n -- proceed according to deck size\n if deckSize \u003e amount then\n for i = 1, amount do\n local card = deck.takeObject({ top = false, flip = true })\n card.deal(1, playerColor)\n end\n else\n -- deal the whole deck\n deck.deal(amount, playerColor)\n\n if deckSize \u003c amount then\n -- Norman Withers handling\n if deckAreaObjects.topCard then\n deckAreaObjects.topCard.deal(1, playerColor)\n deckSize = deckSize + 1\n end\n\n -- warning message for player\n if deckSize \u003c amount then\n printToColor(\"Deck didn't contain enough cards.\", playerColor)\n end\n end\n end\n printToColor(\"Handle the drawn cards according to the ability text on 'Scroll of Secrets'.\", playerColor)\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat to the first empty spot from the right \n ---@param matColor string Playermat that triggered this\n ---@param position tts__Vector Position for the encounter card\n MythosAreaApi.drawEncounterCard = function(matColor, position)\n getMythosArea().call(\"drawEncounterCard\", { matColor = matColor, position = position })\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -186453,7 +186771,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ScrollofSecrets\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat\n ---@param mat tts__Object Playermat that triggered this\n ---@param alwaysFaceUp boolean Whether the card should be drawn face-up\n MythosAreaApi.drawEncounterCard = function(mat, alwaysFaceUp)\n getMythosArea().call(\"drawEncounterCard\", {mat = mat, alwaysFaceUp = alwaysFaceUp})\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"playercards/cards/ScrollofSecrets\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between the lvl 0 and lvl 3 versions of Scroll of Secrets\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- get class via metadata and create context menu accordingly\nfunction onLoad()\n local notes = JSON.decode(self.getGMNotes())\n if notes then\n createContextMenu(notes.id)\n else\n print(\"Missing metadata for Scroll of Secrets!\")\n end\nend\n\nfunction createContextMenu(id)\n if id == \"05116\" or id == \"05116-t\" then\n -- lvl 0: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n elseif id == \"05188\" or id == \"05188-t\" then\n -- seeker lvl 3: draw 3 cards from the bottom\n self.addContextMenuItem(\"Draw bottom card(s)\", function(playerColor) contextFunc(playerColor, 3) end)\n elseif id == \"05189\" or id == \"05189-t\" then\n -- mystic lvl 3: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n end\nend\n\nfunction contextFunc(playerColor, amount)\n local options = { \"Encounter Deck\" }\n\n -- check for players with a deck and only display them as option\n for _, color in ipairs(Player.getAvailableColors()) do\n local matColor = playmatApi.getMatColor(color)\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n\n if deckAreaObjects.draw or deckAreaObjects.topCard then\n table.insert(options, color)\n end\n end\n\n -- show the target selection dialog\n Player[playerColor].showOptionsDialog(\"Select target deck\", options, _, function(owner) drawCardsFromBottom(playerColor, owner, amount) end)\nend\n\nfunction drawCardsFromBottom(playerColor, owner, amount)\n -- variable initialization\n local deck = nil\n local deckSize = 1\n local deckAreaObjects = {}\n\n -- get the respective deck\n if owner == \"Encounter Deck\" then\n deck = mythosAreaApi.getEncounterDeck()\n else\n local matColor = playmatApi.getMatColor(owner)\n deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n deck = deckAreaObjects.draw\n end\n\n -- error handling\n if not deck then\n printToColor(\"Couldn't find deck!\", playerColor)\n return\n end\n\n -- set deck size if there is actually a deck and not just a card\n if deck.type == \"Deck\" then\n deckSize = #deck.getObjects()\n end\n\n -- proceed according to deck size\n if deckSize \u003e amount then\n for i = 1, amount do\n local card = deck.takeObject({ top = false, flip = true })\n card.deal(1, playerColor)\n end\n else\n -- deal the whole deck\n deck.deal(amount, playerColor)\n\n if deckSize \u003c amount then\n -- Norman Withers handling\n if deckAreaObjects.topCard then\n deckAreaObjects.topCard.deal(1, playerColor)\n deckSize = deckSize + 1\n end\n\n -- warning message for player\n if deckSize \u003c amount then\n printToColor(\"Deck didn't contain enough cards.\", playerColor)\n end\n end\n end\n printToColor(\"Handle the drawn cards according to the ability text on 'Scroll of Secrets'.\", playerColor)\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ScrollofSecrets\")\nend)\n__bundle_register(\"playercards/cards/ScrollofSecrets\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between the lvl 0 and lvl 3 versions of Scroll of Secrets\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- get class via metadata and create context menu accordingly\nfunction onLoad()\n local notes = JSON.decode(self.getGMNotes())\n if notes then\n createContextMenu(notes.id)\n else\n print(\"Missing metadata for Scroll of Secrets!\")\n end\nend\n\nfunction createContextMenu(id)\n if id == \"05116\" or id == \"05116-t\" then\n -- lvl 0: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n elseif id == \"05188\" or id == \"05188-t\" then\n -- seeker lvl 3: draw 3 cards from the bottom\n self.addContextMenuItem(\"Draw bottom card(s)\", function(playerColor) contextFunc(playerColor, 3) end)\n elseif id == \"05189\" or id == \"05189-t\" then\n -- mystic lvl 3: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n end\nend\n\nfunction contextFunc(playerColor, amount)\n local options = { \"Encounter Deck\" }\n\n -- check for players with a deck and only display them as option\n for _, color in ipairs(Player.getAvailableColors()) do\n local matColor = playmatApi.getMatColor(color)\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n\n if deckAreaObjects.draw or deckAreaObjects.topCard then\n table.insert(options, color)\n end\n end\n\n -- show the target selection dialog\n Player[playerColor].showOptionsDialog(\"Select target deck\", options, _, function(owner) drawCardsFromBottom(playerColor, owner, amount) end)\nend\n\nfunction drawCardsFromBottom(playerColor, owner, amount)\n -- variable initialization\n local deck = nil\n local deckSize = 1\n local deckAreaObjects = {}\n\n -- get the respective deck\n if owner == \"Encounter Deck\" then\n deck = mythosAreaApi.getEncounterDeck()\n else\n local matColor = playmatApi.getMatColor(owner)\n deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n deck = deckAreaObjects.draw\n end\n\n -- error handling\n if not deck then\n printToColor(\"Couldn't find deck!\", playerColor)\n return\n end\n\n -- set deck size if there is actually a deck and not just a card\n if deck.type == \"Deck\" then\n deckSize = #deck.getObjects()\n end\n\n -- proceed according to deck size\n if deckSize \u003e amount then\n for i = 1, amount do\n local card = deck.takeObject({ top = false, flip = true })\n card.deal(1, playerColor)\n end\n else\n -- deal the whole deck\n deck.deal(amount, playerColor)\n\n if deckSize \u003c amount then\n -- Norman Withers handling\n if deckAreaObjects.topCard then\n deckAreaObjects.topCard.deal(1, playerColor)\n deckSize = deckSize + 1\n end\n\n -- warning message for player\n if deckSize \u003c amount then\n printToColor(\"Deck didn't contain enough cards.\", playerColor)\n end\n end\n end\n printToColor(\"Handle the drawn cards according to the ability text on 'Scroll of Secrets'.\", playerColor)\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat to the first empty spot from the right \n ---@param matColor string Playermat that triggered this\n ---@param position tts__Vector Position for the encounter card\n MythosAreaApi.drawEncounterCard = function(matColor, position)\n getMythosArea().call(\"drawEncounterCard\", { matColor = matColor, position = position })\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -187255,7 +187573,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ScrollofSecrets\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat\n ---@param mat tts__Object Playermat that triggered this\n ---@param alwaysFaceUp boolean Whether the card should be drawn face-up\n MythosAreaApi.drawEncounterCard = function(mat, alwaysFaceUp)\n getMythosArea().call(\"drawEncounterCard\", {mat = mat, alwaysFaceUp = alwaysFaceUp})\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"playercards/cards/ScrollofSecrets\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between the lvl 0 and lvl 3 versions of Scroll of Secrets\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- get class via metadata and create context menu accordingly\nfunction onLoad()\n local notes = JSON.decode(self.getGMNotes())\n if notes then\n createContextMenu(notes.id)\n else\n print(\"Missing metadata for Scroll of Secrets!\")\n end\nend\n\nfunction createContextMenu(id)\n if id == \"05116\" or id == \"05116-t\" then\n -- lvl 0: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n elseif id == \"05188\" or id == \"05188-t\" then\n -- seeker lvl 3: draw 3 cards from the bottom\n self.addContextMenuItem(\"Draw bottom card(s)\", function(playerColor) contextFunc(playerColor, 3) end)\n elseif id == \"05189\" or id == \"05189-t\" then\n -- mystic lvl 3: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n end\nend\n\nfunction contextFunc(playerColor, amount)\n local options = { \"Encounter Deck\" }\n\n -- check for players with a deck and only display them as option\n for _, color in ipairs(Player.getAvailableColors()) do\n local matColor = playmatApi.getMatColor(color)\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n\n if deckAreaObjects.draw or deckAreaObjects.topCard then\n table.insert(options, color)\n end\n end\n\n -- show the target selection dialog\n Player[playerColor].showOptionsDialog(\"Select target deck\", options, _, function(owner) drawCardsFromBottom(playerColor, owner, amount) end)\nend\n\nfunction drawCardsFromBottom(playerColor, owner, amount)\n -- variable initialization\n local deck = nil\n local deckSize = 1\n local deckAreaObjects = {}\n\n -- get the respective deck\n if owner == \"Encounter Deck\" then\n deck = mythosAreaApi.getEncounterDeck()\n else\n local matColor = playmatApi.getMatColor(owner)\n deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n deck = deckAreaObjects.draw\n end\n\n -- error handling\n if not deck then\n printToColor(\"Couldn't find deck!\", playerColor)\n return\n end\n\n -- set deck size if there is actually a deck and not just a card\n if deck.type == \"Deck\" then\n deckSize = #deck.getObjects()\n end\n\n -- proceed according to deck size\n if deckSize \u003e amount then\n for i = 1, amount do\n local card = deck.takeObject({ top = false, flip = true })\n card.deal(1, playerColor)\n end\n else\n -- deal the whole deck\n deck.deal(amount, playerColor)\n\n if deckSize \u003c amount then\n -- Norman Withers handling\n if deckAreaObjects.topCard then\n deckAreaObjects.topCard.deal(1, playerColor)\n deckSize = deckSize + 1\n end\n\n -- warning message for player\n if deckSize \u003c amount then\n printToColor(\"Deck didn't contain enough cards.\", playerColor)\n end\n end\n end\n printToColor(\"Handle the drawn cards according to the ability text on 'Scroll of Secrets'.\", playerColor)\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/cards/ScrollofSecrets\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- this script is shared between the lvl 0 and lvl 3 versions of Scroll of Secrets\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- get class via metadata and create context menu accordingly\nfunction onLoad()\n local notes = JSON.decode(self.getGMNotes())\n if notes then\n createContextMenu(notes.id)\n else\n print(\"Missing metadata for Scroll of Secrets!\")\n end\nend\n\nfunction createContextMenu(id)\n if id == \"05116\" or id == \"05116-t\" then\n -- lvl 0: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n elseif id == \"05188\" or id == \"05188-t\" then\n -- seeker lvl 3: draw 3 cards from the bottom\n self.addContextMenuItem(\"Draw bottom card(s)\", function(playerColor) contextFunc(playerColor, 3) end)\n elseif id == \"05189\" or id == \"05189-t\" then\n -- mystic lvl 3: draw 1 card from the bottom\n self.addContextMenuItem(\"Draw bottom card\", function(playerColor) contextFunc(playerColor, 1) end)\n end\nend\n\nfunction contextFunc(playerColor, amount)\n local options = { \"Encounter Deck\" }\n\n -- check for players with a deck and only display them as option\n for _, color in ipairs(Player.getAvailableColors()) do\n local matColor = playmatApi.getMatColor(color)\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n\n if deckAreaObjects.draw or deckAreaObjects.topCard then\n table.insert(options, color)\n end\n end\n\n -- show the target selection dialog\n Player[playerColor].showOptionsDialog(\"Select target deck\", options, _, function(owner) drawCardsFromBottom(playerColor, owner, amount) end)\nend\n\nfunction drawCardsFromBottom(playerColor, owner, amount)\n -- variable initialization\n local deck = nil\n local deckSize = 1\n local deckAreaObjects = {}\n\n -- get the respective deck\n if owner == \"Encounter Deck\" then\n deck = mythosAreaApi.getEncounterDeck()\n else\n local matColor = playmatApi.getMatColor(owner)\n deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n deck = deckAreaObjects.draw\n end\n\n -- error handling\n if not deck then\n printToColor(\"Couldn't find deck!\", playerColor)\n return\n end\n\n -- set deck size if there is actually a deck and not just a card\n if deck.type == \"Deck\" then\n deckSize = #deck.getObjects()\n end\n\n -- proceed according to deck size\n if deckSize \u003e amount then\n for i = 1, amount do\n local card = deck.takeObject({ top = false, flip = true })\n card.deal(1, playerColor)\n end\n else\n -- deal the whole deck\n deck.deal(amount, playerColor)\n\n if deckSize \u003c amount then\n -- Norman Withers handling\n if deckAreaObjects.topCard then\n deckAreaObjects.topCard.deal(1, playerColor)\n deckSize = deckSize + 1\n end\n\n -- warning message for player\n if deckSize \u003c amount then\n printToColor(\"Deck didn't contain enough cards.\", playerColor)\n end\n end\n end\n printToColor(\"Handle the drawn cards according to the ability text on 'Scroll of Secrets'.\", playerColor)\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat to the first empty spot from the right \n ---@param matColor string Playermat that triggered this\n ---@param position tts__Vector Position for the encounter card\n MythosAreaApi.drawEncounterCard = function(matColor, position)\n getMythosArea().call(\"drawEncounterCard\", { matColor = matColor, position = position })\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/cards/ScrollofSecrets\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -187983,7 +188301,7 @@ }, "Description": "Unidentified", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"10044\",\n \"type\": \"Asset\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 0,\n \"traits\": \"Creature. Monster. Flora. Science.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"10045\"\n }\n ],\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Growth\",\n \"token\": \"resource\"\n }\n ],\n \"agilityIcons\": 1,\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GMNotes": "{\n \"id\": \"10044\",\n \"type\": \"Asset\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 0,\n \"traits\": \"Creature. Monster. Flora. Science.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10045\"\n }\n ],\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Growth\",\n \"token\": \"resource\"\n }\n ],\n \"agilityIcons\": 1,\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", "GUID": "0aa967", "Grid": true, "GridProjection": false, @@ -189644,7 +189962,7 @@ }, "Description": "The Farmhand", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"10015\",\n \"type\": \"Investigator\",\n \"class\": \"Survivor\",\n \"traits\": \"Assistant. Warden.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"10015-b1\"\n },\n {\n \"count\": 1,\n \"id\": \"10015-b2\"\n }\n ],\n \"willpowerIcons\": 3,\n \"intellectIcons\": 1,\n \"combatIcons\": 5,\n \"agilityIcons\": 3,\n \"cycle\": \"The Feast of Hemlock Vale\",\n \"deck_requirements\": {\n \"size\": 35,\n \"randomBasicWeaknessCount\": 1,\n \"signatures\": [\n {\n \"10017\": 1\n },\n {\n \"10018\": 1\n }\n ]\n },\n \"deck_options\": [\n {\n \"faction\": [\n \"seeker\",\n \"neutral\"\n ],\n \"level\": {\n \"min\": 0,\n \"max\": 5\n }\n },\n {\n \"trait\": [\n \"insight\",\n \"spirit\"\n ],\n \"level\": {\n \"min\": 0,\n \"max\": 2\n },\n \"limit\": 10\n }\n ]\n}", + "GMNotes": "{\n \"id\": \"10015\",\n \"type\": \"Investigator\",\n \"class\": \"Survivor\",\n \"traits\": \"Assistant. Warden.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10015-b1\"\n },\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10015-b2\"\n }\n ],\n \"willpowerIcons\": 3,\n \"intellectIcons\": 1,\n \"combatIcons\": 5,\n \"agilityIcons\": 3,\n \"cycle\": \"The Feast of Hemlock Vale\",\n \"deck_requirements\": {\n \"size\": 35,\n \"randomBasicWeaknessCount\": 1,\n \"signatures\": [\n {\n \"10017\": 1\n },\n {\n \"10018\": 1\n }\n ]\n },\n \"deck_options\": [\n {\n \"faction\": [\n \"seeker\",\n \"neutral\"\n ],\n \"level\": {\n \"min\": 0,\n \"max\": 5\n }\n },\n {\n \"trait\": [\n \"insight\",\n \"spirit\"\n ],\n \"level\": {\n \"min\": 0,\n \"max\": 2\n },\n \"limit\": 10\n }\n ]\n}", "GUID": "3764cd", "Grid": true, "GridProjection": false, @@ -191120,7 +191438,7 @@ }, "Description": "Singing Your Song", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"10062\",\n \"type\": \"Asset\",\n \"slot\": \"Ally\",\n \"class\": \"Rogue\",\n \"cost\": 2,\n \"level\": 0,\n \"traits\": \"Ally. Criminal. Socialite.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"10063\"\n }\n ],\n \"agilityIcons\": 1,\n \"uses\": [\n {\n \"count\": 10,\n \"type\": \"Resource\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GMNotes": "{\n \"id\": \"10062\",\n \"type\": \"Asset\",\n \"slot\": \"Ally\",\n \"class\": \"Rogue\",\n \"cost\": 2,\n \"level\": 0,\n \"traits\": \"Ally. Criminal. Socialite.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10063\"\n }\n ],\n \"agilityIcons\": 1,\n \"uses\": [\n {\n \"count\": 10,\n \"type\": \"Resource\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", "GUID": "897a94", "Grid": true, "GridProjection": false, @@ -191488,7 +191806,7 @@ }, "Description": "Carnivorous Strain", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"10060\",\n \"type\": \"Asset\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 4,\n \"traits\": \"Monster. Science.\",\n \"combatIcons\": 1,\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"10045\"\n }\n ],\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Growth\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GMNotes": "{\n \"id\": \"10060\",\n \"type\": \"Asset\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 4,\n \"traits\": \"Monster. Science.\",\n \"combatIcons\": 1,\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10045\"\n }\n ],\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Growth\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", "GUID": "df93ca", "Grid": true, "GridProjection": false, @@ -192041,7 +192359,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"10105\",\n \"type\": \"Event\",\n \"class\": \"Mystic\",\n \"cost\": 0,\n \"level\": 5,\n \"traits\": \"Spell. Pact. Blessed. Cursed.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"10106\"\n },\n {\n \"count\": 1,\n \"id\": \"10107\"\n }\n ],\n \"willpowerIcons\": 1,\n \"combatIcons\": 1,\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GMNotes": "{\n \"id\": \"10105\",\n \"type\": \"Event\",\n \"class\": \"Mystic\",\n \"cost\": 0,\n \"level\": 5,\n \"traits\": \"Spell. Pact. Blessed. Cursed.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10106\"\n },\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10107\"\n }\n ],\n \"willpowerIcons\": 1,\n \"combatIcons\": 1,\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", "GUID": "d2b649", "Grid": true, "GridProjection": false, @@ -193026,7 +193344,7 @@ }, "Description": "Scepter of the Mad Seer", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"10085\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Mystic\",\n \"cost\": 2,\n \"level\": 0,\n \"traits\": \"Item. Relic. Occult. Cursed.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"10086\"\n },\n {\n \"count\": 1,\n \"id\": \"10087\"\n },\n {\n \"count\": 1,\n \"id\": \"10088\"\n },\n {\n \"count\": 1,\n \"id\": \"10089\"\n },\n {\n \"count\": 1,\n \"id\": \"10090\"\n }\n ],\n \"willpowerIcons\": 1,\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GMNotes": "{\n \"id\": \"10085\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Mystic\",\n \"cost\": 2,\n \"level\": 0,\n \"traits\": \"Item. Relic. Occult. Cursed.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10086\"\n },\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10087\"\n },\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10088\"\n },\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10089\"\n },\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10090\"\n }\n ],\n \"willpowerIcons\": 1,\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", "GUID": "66ec64", "Grid": true, "GridProjection": false, @@ -193272,7 +193590,7 @@ }, "Description": "Sentient Strain", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"10059\",\n \"type\": \"Asset\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 4,\n \"traits\": \"Creature. Science.\",\n \"intellectIcons\": 1,\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"10045\"\n }\n ],\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Growth\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GMNotes": "{\n \"id\": \"10059\",\n \"type\": \"Asset\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 4,\n \"traits\": \"Creature. Science.\",\n \"intellectIcons\": 1,\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10045\"\n }\n ],\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Growth\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", "GUID": "ab2752", "Grid": true, "GridProjection": false, @@ -193334,7 +193652,7 @@ }, "Description": "Scepter of the Mad Seer", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"10098\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Mystic\",\n \"cost\": 2,\n \"level\": 2,\n \"traits\": \"Item. Relic. Occult. Cursed.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"10086\"\n },\n {\n \"count\": 1,\n \"id\": \"10087\"\n },\n {\n \"count\": 1,\n \"id\": \"10088\"\n },\n {\n \"count\": 1,\n \"id\": \"10089\"\n },\n {\n \"count\": 1,\n \"id\": \"10090\"\n }\n ],\n \"willpowerIcons\": 1,\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GMNotes": "{\n \"id\": \"10098\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Mystic\",\n \"cost\": 2,\n \"level\": 2,\n \"traits\": \"Item. Relic. Occult. Cursed.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10086\"\n },\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10087\"\n },\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10088\"\n },\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10089\"\n },\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10090\"\n }\n ],\n \"willpowerIcons\": 1,\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", "GUID": "d8ef99", "Grid": true, "GridProjection": false, @@ -193827,7 +194145,7 @@ }, "Description": "The Mother's Cunning", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"10035\",\n \"type\": \"Asset\",\n \"slot\": \"Hand|Arcane\",\n \"class\": \"Guardian\",\n \"cost\": 3,\n \"level\": 4,\n \"traits\": \"Item. Relic. Spell.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"10036\"\n }\n ],\n \"willpowerIcons\": 1,\n \"combatIcons\": 1,\n \"uses\": [\n {\n \"type\": \"Charge\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GMNotes": "{\n \"id\": \"10035\",\n \"type\": \"Asset\",\n \"slot\": \"Hand|Arcane\",\n \"class\": \"Guardian\",\n \"cost\": 3,\n \"level\": 4,\n \"traits\": \"Item. Relic. Spell.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 2,\n \"id\": \"10036\"\n }\n ],\n \"willpowerIcons\": 1,\n \"combatIcons\": 1,\n \"uses\": [\n {\n \"type\": \"Charge\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", "GUID": "e7bfbe", "Grid": true, "GridProjection": false, @@ -194012,7 +194330,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"10038\",\n \"type\": \"Event\",\n \"class\": \"Guardian\",\n \"level\": 5,\n \"traits\": \"Favor. Blessed.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"10039\"\n }\n ],\n \"willpowerIcons\": 1,\n \"wildIcons\": 1,\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GMNotes": "{\n \"id\": \"10038\",\n \"type\": \"Event\",\n \"class\": \"Guardian\",\n \"level\": 5,\n \"traits\": \"Favor. Blessed.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 2,\n \"id\": \"10039\"\n }\n ],\n \"willpowerIcons\": 1,\n \"wildIcons\": 1,\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", "GUID": "d78d4a", "Grid": true, "GridProjection": false, @@ -194196,7 +194514,7 @@ }, "Description": "Nurturing Strain", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"10061\",\n \"type\": \"Asset\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 4,\n \"traits\": \"Flora. Science.\",\n \"willpowerIcons\": 1,\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"10045\"\n }\n ],\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Growth\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GMNotes": "{\n \"id\": \"10061\",\n \"type\": \"Asset\",\n \"class\": \"Seeker\",\n \"cost\": 2,\n \"level\": 4,\n \"traits\": \"Flora. Science.\",\n \"willpowerIcons\": 1,\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10045\"\n }\n ],\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Growth\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", "GUID": "baa926", "Grid": true, "GridProjection": false, @@ -194258,7 +194576,7 @@ }, "Description": "Crown of Dying Light", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"10133\",\n \"type\": \"Asset\",\n \"class\": \"Neutral\",\n \"cost\": 1,\n \"level\": 5,\n \"traits\": \"Item. Charm. Mask.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"id\": \"10134\"\n }\n ],\n \"wildIcons\": 1,\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Offering\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GMNotes": "{\n \"id\": \"10133\",\n \"type\": \"Asset\",\n \"class\": \"Neutral\",\n \"cost\": 1,\n \"level\": 5,\n \"traits\": \"Item. Charm. Mask.\",\n \"bonded\": [\n {\n \"count\": 1,\n \"maxCount\": 1,\n \"id\": \"10134\"\n }\n ],\n \"wildIcons\": 1,\n \"uses\": [\n {\n \"count\": 0,\n \"type\": \"Offering\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", "GUID": "b6d35d", "Grid": true, "GridProjection": false, @@ -194538,6 +194856,563 @@ }, "Value": 0, "XmlUI": "" + }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "CardID": 536427, + "ColorDiffuse": { + "b": 0.71324, + "g": 0.71324, + "r": 0.71324 + }, + "CustomDeck": { + "5364": { + "BackIsHidden": true, + "BackURL": "http://cloud-3.steamusercontent.com/ugc/2342503777940352139/A2D42E7E5C43D045D72CE5CFC907E4F886C8C690/", + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2453969772006048567/4C173CF8E2E2F69C7374D65AAA2D842C048FC792/", + "NumHeight": 5, + "NumWidth": 8, + "Type": 0, + "UniqueBack": false + } + }, + "Description": "Best in Her Field", + "DragSelectable": true, + "GMNotes": "{\n \"id\": \"10702\",\n \"type\": \"Asset\",\n \"slot\": \"Ally\",\n \"class\": \"Neutral\",\n \"cost\": 4,\n \"traits\": \"Ally. Miskatonic. Wayfarer.\",\n \"intellectIcons\": 1,\n \"agilityIcons\": 1,\n \"wildIcons\": 1,\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GUID": "62d5a6", + "Grid": true, + "GridProjection": false, + "Hands": true, + "HideWhenFaceDown": true, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Card", + "Nickname": "Dr. Rosa Marquez", + "SidewaysCard": false, + "Snap": true, + "Sticky": true, + "Tags": [ + "Asset", + "PlayerCard" + ], + "Tooltip": true, + "Transform": { + "posX": 31.166, + "posY": 3.67, + "posZ": 13.98, + "rotX": 0, + "rotY": 270, + "rotZ": 0, + "scaleX": 1, + "scaleY": 1, + "scaleZ": 1 + }, + "Value": 0, + "XmlUI": "" + }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "CardID": 536431, + "ColorDiffuse": { + "b": 0.71324, + "g": 0.71324, + "r": 0.71324 + }, + "CustomDeck": { + "5364": { + "BackIsHidden": true, + "BackURL": "http://cloud-3.steamusercontent.com/ugc/2342503777940352139/A2D42E7E5C43D045D72CE5CFC907E4F886C8C690/", + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2453969772006048567/4C173CF8E2E2F69C7374D65AAA2D842C048FC792/", + "NumHeight": 5, + "NumWidth": 8, + "Type": 0, + "UniqueBack": false + } + }, + "Description": "A Grim Account", + "DragSelectable": true, + "GMNotes": "{\n \"id\": \"10715\",\n \"type\": \"Asset\",\n \"slot\": \"Hand\",\n \"class\": \"Neutral\",\n \"cost\": 1,\n \"traits\": \"Item. Tome.\",\n \"intellectIcons\": 1,\n \"agilityIcons\": 1,\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GUID": "34a7b5", + "Grid": true, + "GridProjection": false, + "Hands": true, + "HideWhenFaceDown": true, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Card", + "Nickname": "The Pearl Diary", + "SidewaysCard": false, + "Snap": true, + "Sticky": true, + "Tags": [ + "Asset", + "PlayerCard" + ], + "Tooltip": true, + "Transform": { + "posX": 31.166, + "posY": 3.67, + "posZ": 9.405, + "rotX": 0, + "rotY": 270, + "rotZ": 0, + "scaleX": 1, + "scaleY": 1, + "scaleZ": 1 + }, + "Value": 0, + "XmlUI": "" + }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "CardID": 537606, + "ColorDiffuse": { + "b": 0.71324, + "g": 0.71324, + "r": 0.71324 + }, + "CustomDeck": { + "5376": { + "BackIsHidden": true, + "BackURL": "http://cloud-3.steamusercontent.com/ugc/2342503777940352139/A2D42E7E5C43D045D72CE5CFC907E4F886C8C690/", + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2453969772006056023/3B1E7D4CD84213ED69594B15606531799383F4AA/", + "NumHeight": 3, + "NumWidth": 9, + "Type": 0, + "UniqueBack": false + } + }, + "Description": "Faithful Steed", + "DragSelectable": true, + "GMNotes": "{\n \"id\": \"10642\",\n \"type\": \"Asset\",\n \"slot\": \"Ally\",\n \"class\": \"Neutral\",\n \"cost\": 2,\n \"traits\": \"Ally. Creature.\",\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GUID": "f8a7c6", + "Grid": true, + "GridProjection": false, + "Hands": true, + "HideWhenFaceDown": true, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Card", + "Nickname": "Ajax", + "SidewaysCard": false, + "Snap": true, + "Sticky": true, + "Tags": [ + "Asset", + "PlayerCard" + ], + "Tooltip": true, + "Transform": { + "posX": 31.166, + "posY": 3.67, + "posZ": 11.693, + "rotX": 0, + "rotY": 270, + "rotZ": 0, + "scaleX": 1, + "scaleY": 1, + "scaleZ": 1 + }, + "Value": 0, + "XmlUI": "" + }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "CardID": 536430, + "ColorDiffuse": { + "b": 0.71324, + "g": 0.71324, + "r": 0.71324 + }, + "CustomDeck": { + "5364": { + "BackIsHidden": true, + "BackURL": "http://cloud-3.steamusercontent.com/ugc/2342503777940352139/A2D42E7E5C43D045D72CE5CFC907E4F886C8C690/", + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2453969772006048567/4C173CF8E2E2F69C7374D65AAA2D842C048FC792/", + "NumHeight": 5, + "NumWidth": 8, + "Type": 0, + "UniqueBack": false + } + }, + "Description": "Symbol of Innocence", + "DragSelectable": true, + "GMNotes": "{\n \"id\": \"10714\",\n \"type\": \"Asset\",\n \"slot\": \"Accessory\",\n \"class\": \"Neutral\",\n \"cost\": 1,\n \"willpowerIcons\": 1,\n \"agilityIcons\": 1,\n \"uses\": [\n {\n \"count\": 3,\n \"type\": \"Wish\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GUID": "3602f5", + "Grid": true, + "GridProjection": false, + "Hands": true, + "HideWhenFaceDown": true, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Card", + "Nickname": "Corn Husk Doll", + "SidewaysCard": false, + "Snap": true, + "Sticky": true, + "Tags": [ + "Asset", + "PlayerCard" + ], + "Tooltip": true, + "Transform": { + "posX": 34.328, + "posY": 3.67, + "posZ": 9.405, + "rotX": 0, + "rotY": 270, + "rotZ": 0, + "scaleX": 1, + "scaleY": 1, + "scaleZ": 1 + }, + "Value": 0, + "XmlUI": "" + }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "CardID": 536434, + "ColorDiffuse": { + "b": 0.71324, + "g": 0.71324, + "r": 0.71324 + }, + "CustomDeck": { + "5364": { + "BackIsHidden": true, + "BackURL": "http://cloud-3.steamusercontent.com/ugc/2342503777940352139/A2D42E7E5C43D045D72CE5CFC907E4F886C8C690/", + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2453969772006048567/4C173CF8E2E2F69C7374D65AAA2D842C048FC792/", + "NumHeight": 5, + "NumWidth": 8, + "Type": 0, + "UniqueBack": false + } + }, + "Description": "Withered Flesh", + "DragSelectable": true, + "GMNotes": "{\n \"id\": \"10685\",\n \"type\": \"Skill\",\n \"traits\": \"Blight. Colour.\",\n \"weakness\": true,\n \"wildIcons\": 1,\n \"negativeIcons\": true,\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GUID": "0d0a2c", + "Grid": true, + "GridProjection": false, + "Hands": true, + "HideWhenFaceDown": true, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Card", + "Nickname": "The Hemlock Curse", + "SidewaysCard": false, + "Snap": true, + "Sticky": true, + "Tags": [ + "PlayerCard" + ], + "Tooltip": true, + "Transform": { + "posX": 37.491, + "posY": 3.67, + "posZ": 9.405, + "rotX": 0, + "rotY": 270, + "rotZ": 0, + "scaleX": 1, + "scaleY": 1, + "scaleZ": 1 + }, + "Value": 0, + "XmlUI": "" + }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "CardID": 536429, + "ColorDiffuse": { + "b": 0.71324, + "g": 0.71324, + "r": 0.71324 + }, + "CustomDeck": { + "5364": { + "BackIsHidden": true, + "BackURL": "http://cloud-3.steamusercontent.com/ugc/2342503777940352139/A2D42E7E5C43D045D72CE5CFC907E4F886C8C690/", + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2453969772006048567/4C173CF8E2E2F69C7374D65AAA2D842C048FC792/", + "NumHeight": 5, + "NumWidth": 8, + "Type": 0, + "UniqueBack": false + } + }, + "Description": "Token of Safety", + "DragSelectable": true, + "GMNotes": "{\n \"id\": \"10713\",\n \"type\": \"Asset\",\n \"slot\": \"Accessory\",\n \"class\": \"Neutral\",\n \"cost\": 1,\n \"traits\": \"Item. Charm. Blessed.\",\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GUID": "5e5dc6", + "Grid": true, + "GridProjection": false, + "Hands": true, + "HideWhenFaceDown": true, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Card", + "Nickname": "Worry Rock", + "SidewaysCard": false, + "Snap": true, + "Sticky": true, + "Tags": [ + "Asset", + "PlayerCard" + ], + "Tooltip": true, + "Transform": { + "posX": 34.328, + "posY": 3.67, + "posZ": 11.693, + "rotX": 0, + "rotY": 270, + "rotZ": 0, + "scaleX": 1, + "scaleY": 1, + "scaleZ": 1 + }, + "Value": 0, + "XmlUI": "" + }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "CardID": 536811, + "ColorDiffuse": { + "b": 0.71324, + "g": 0.71324, + "r": 0.71324 + }, + "CustomDeck": { + "5368": { + "BackIsHidden": true, + "BackURL": "http://cloud-3.steamusercontent.com/ugc/2342503777940352139/A2D42E7E5C43D045D72CE5CFC907E4F886C8C690/", + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2453969772006052261/19972DA9635CE5C7AD74D9BDAE6196359172335A/", + "NumHeight": 2, + "NumWidth": 7, + "Type": 0, + "UniqueBack": false + } + }, + "Description": "A Cracked Memento", + "DragSelectable": true, + "GMNotes": "{\n \"id\": \"10548\",\n \"type\": \"Asset\",\n \"slot\": \"Accessory\",\n \"class\": \"Neutral\",\n \"cost\": 1,\n \"traits\": \"Item. Charm. Cursed.\",\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GUID": "153a42", + "Grid": true, + "GridProjection": false, + "Hands": true, + "HideWhenFaceDown": true, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Card", + "Nickname": "Little Sylvie", + "SidewaysCard": false, + "Snap": true, + "Sticky": true, + "Tags": [ + "Asset", + "PlayerCard" + ], + "Tooltip": true, + "Transform": { + "posX": 37.491, + "posY": 3.67, + "posZ": 11.693, + "rotX": 0, + "rotY": 270, + "rotZ": 0, + "scaleX": 1, + "scaleY": 1, + "scaleZ": 1 + }, + "Value": 0, + "XmlUI": "" + }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "CardID": 536806, + "ColorDiffuse": { + "b": 0.71324, + "g": 0.71324, + "r": 0.71324 + }, + "CustomDeck": { + "5368": { + "BackIsHidden": true, + "BackURL": "http://cloud-3.steamusercontent.com/ugc/2342503777940352139/A2D42E7E5C43D045D72CE5CFC907E4F886C8C690/", + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2453969772006052261/19972DA9635CE5C7AD74D9BDAE6196359172335A/", + "NumHeight": 2, + "NumWidth": 7, + "Type": 0, + "UniqueBack": false + } + }, + "Description": "Alien Meteorite", + "DragSelectable": true, + "GMNotes": "{\n \"id\": \"10522\",\n \"type\": \"Asset\",\n \"class\": \"Neutral\",\n \"cost\": 2,\n \"traits\": \"Item. Relic. Colour.\",\n \"uses\": [\n {\n \"count\": 4,\n \"type\": \"Brilliance\",\n \"token\": \"resource\"\n }\n ],\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GUID": "27fe24", + "Grid": true, + "GridProjection": false, + "Hands": true, + "HideWhenFaceDown": true, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Card", + "Nickname": "Prismatic Shard", + "SidewaysCard": false, + "Snap": true, + "Sticky": true, + "Tags": [ + "Asset", + "PlayerCard" + ], + "Tooltip": true, + "Transform": { + "posX": 34.328, + "posY": 3.67, + "posZ": 13.98, + "rotX": 0, + "rotY": 270, + "rotZ": 0, + "scaleX": 1, + "scaleY": 1, + "scaleZ": 1 + }, + "Value": 0, + "XmlUI": "" + }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "CardID": 536428, + "ColorDiffuse": { + "b": 0.71324, + "g": 0.71324, + "r": 0.71324 + }, + "CustomDeck": { + "5364": { + "BackIsHidden": true, + "BackURL": "http://cloud-3.steamusercontent.com/ugc/2342503777940352139/A2D42E7E5C43D045D72CE5CFC907E4F886C8C690/", + "FaceURL": "http://cloud-3.steamusercontent.com/ugc/2453969772006048567/4C173CF8E2E2F69C7374D65AAA2D842C048FC792/", + "NumHeight": 5, + "NumWidth": 8, + "Type": 0, + "UniqueBack": false + } + }, + "Description": "The Eldest Sister", + "DragSelectable": true, + "GMNotes": "{\n \"id\": \"10703\",\n \"type\": \"Asset\",\n \"slot\": \"Ally\",\n \"class\": \"Neutral\",\n \"cost\": 3,\n \"traits\": \"Ally. Hunter.\",\n \"willpowerIcons\": 1,\n \"combatIcons\": 1,\n \"wildIcons\": 1,\n \"cycle\": \"The Feast of Hemlock Vale\"\n}", + "GUID": "33bfa1", + "Grid": true, + "GridProjection": false, + "Hands": true, + "HideWhenFaceDown": true, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Card", + "Nickname": "Helen Peters", + "SidewaysCard": false, + "Snap": true, + "Sticky": true, + "Tags": [ + "Asset", + "PlayerCard" + ], + "Tooltip": true, + "Transform": { + "posX": 37.491, + "posY": 3.67, + "posZ": 13.98, + "rotX": 0, + "rotY": 270, + "rotZ": 0, + "scaleX": 1, + "scaleY": 1, + "scaleZ": 1 + }, + "Value": 0, + "XmlUI": "" } ], "Description": "", @@ -194551,7 +195426,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/AllCardsBag\")\nend)\n__bundle_register(\"playercards/AllCardsBag\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal cardIdIndex = { }\nlocal classAndLevelIndex = { }\nlocal basicWeaknessList = { }\nlocal uniqueWeaknessList = { }\nlocal cycleIndex = { }\n\nlocal indexingDone = false\n\nfunction onLoad()\n self.addContextMenuItem(\"Rebuild Index\", startIndexBuild)\n math.randomseed(os.time())\n Wait.frames(startIndexBuild, 30)\nend\n\n-- Called by Hotfix bags when they load. If we are still loading indexes, then\n-- the all cards and hotfix bags are being loaded together, and we can ignore\n-- this call as the hotfix will be included in the initial indexing. If it is\n-- called once indexing is complete it means the hotfix bag has been added\n-- later, and we should rebuild the index to integrate the hotfix bag.\nfunction rebuildIndexForHotfix()\n if (indexingDone) then\n startIndexBuild()\n end\nend\n\n-- Resets all current bag indexes\nfunction clearIndexes()\n indexingDone = false\n cardIdIndex = { }\n classAndLevelIndex = { }\n classAndLevelIndex[\"Guardian-upgrade\"] = { }\n classAndLevelIndex[\"Seeker-upgrade\"] = { }\n classAndLevelIndex[\"Mystic-upgrade\"] = { }\n classAndLevelIndex[\"Survivor-upgrade\"] = { }\n classAndLevelIndex[\"Rogue-upgrade\"] = { }\n classAndLevelIndex[\"Neutral-upgrade\"] = { }\n classAndLevelIndex[\"Guardian-level0\"] = { }\n classAndLevelIndex[\"Seeker-level0\"] = { }\n classAndLevelIndex[\"Mystic-level0\"] = { }\n classAndLevelIndex[\"Survivor-level0\"] = { }\n classAndLevelIndex[\"Rogue-level0\"] = { }\n classAndLevelIndex[\"Neutral-level0\"] = { }\n cycleIndex = { }\n basicWeaknessList = { }\n uniqueWeaknessList = { }\nend\n\n-- Clears the bag indexes and starts the coroutine to rebuild the indexes\nfunction startIndexBuild()\n clearIndexes()\n startLuaCoroutine(self, \"buildIndex\")\nend\n\nfunction onObjectLeaveContainer(container, _)\n if container == self then\n broadcastToAll(\"Removing cards from the All Player Cards bag may break some functions.\", \"Red\")\n end\nend\n\n-- Create the card indexes by iterating all cards in the bag, parsing their\n-- metadata, and creating the keyed lookup tables for the cards. This is a\n-- coroutine which will spread the workload by processing 20 cards before\n-- yielding. Based on the current count of cards this will require\n-- approximately 60 frames to complete.\nfunction buildIndex()\n local cardCount = 0\n indexingDone = false\n if (self.getData().ContainedObjects == nil) then\n return 1\n end\n for i, cardData in ipairs(self.getData().ContainedObjects) do\n local cardMetadata = JSON.decode(cardData.GMNotes)\n if (cardMetadata ~= nil) then\n addCardToIndex(cardData, cardMetadata)\n cardCount = cardCount + 1\n if cardCount \u003e 9 then\n cardCount = 0\n coroutine.yield(0)\n end\n end\n end\n local hotfixBags = getObjectsWithTag(\"AllCardsHotfix\")\n for _, hotfixBag in ipairs(hotfixBags) do\n if (#hotfixBag.getObjects() \u003e 0) then\n for i, cardData in ipairs(hotfixBag.getData().ContainedObjects) do\n if cardData.ContainedObjects then\n for j, deepCardData in ipairs(cardData.ContainedObjects) do\n local deepCardMetadata = JSON.decode(deepCardData.GMNotes)\n if deepCardMetadata ~= nil then\n addCardToIndex(deepCardData, deepCardMetadata)\n cardCount = cardCount + 1\n if cardCount \u003e 9 then\n cardCount = 0\n coroutine.yield(0)\n end\n end\n end\n else\n local cardMetadata = JSON.decode(cardData.GMNotes)\n if cardMetadata ~= nil then\n addCardToIndex(cardData, cardMetadata)\n cardCount = cardCount + 1\n if cardCount \u003e 9 then\n cardCount = 0\n coroutine.yield(0)\n end\n end\n end\n end\n end\n end\n buildSupplementalIndexes()\n indexingDone = true\n return 1\nend\n\n-- Adds a card to any indexes it should be a part of, based on its metadata.\n---@param cardData table TTS object data for the card\n---@param cardMetadata table SCED metadata for the card\nfunction addCardToIndex(cardData, cardMetadata)\n -- use the ZoopGuid as fallback if no id present\n if cardMetadata.id == nil and cardMetadata.TtsZoopGuid then\n cardMetadata.id = cardMetadata.TtsZoopGuid\n end\n cardIdIndex[cardMetadata.id] = { data = cardData, metadata = cardMetadata }\n if (cardMetadata.alternate_ids ~= nil) then\n for _, alternateId in ipairs(cardMetadata.alternate_ids) do\n cardIdIndex[alternateId] = { data = cardData, metadata = cardMetadata }\n end\n end\nend\n\nfunction buildSupplementalIndexes()\n for cardId, card in pairs(cardIdIndex) do\n local cardMetadata = card.metadata\n -- If the ID key and the metadata ID don't match this is a duplicate card created by an\n -- alternate_id, and we should skip it\n if cardId == cardMetadata.id then\n -- Add card to the basic weakness list, if appropriate. Some weaknesses have\n -- multiple copies, and are added multiple times\n if cardMetadata.weakness then\n table.insert(uniqueWeaknessList, cardMetadata.id)\n if cardMetadata.basicWeaknessCount ~= nil then\n for i = 1, cardMetadata.basicWeaknessCount do\n table.insert(basicWeaknessList, cardMetadata.id)\n end\n end\n end\n\n -- Add the card to the appropriate class and level indexes\n local isGuardian = false\n local isSeeker = false\n local isMystic = false\n local isRogue = false\n local isSurvivor = false\n local isNeutral = false\n local upgradeKey\n -- Excludes signature cards (which have no class or level) and alternate\n -- ID entries\n if (cardMetadata.class ~= nil and cardMetadata.level ~= nil) then\n isGuardian = string.match(cardMetadata.class, \"Guardian\")\n isSeeker = string.match(cardMetadata.class, \"Seeker\")\n isMystic = string.match(cardMetadata.class, \"Mystic\")\n isRogue = string.match(cardMetadata.class, \"Rogue\")\n isSurvivor = string.match(cardMetadata.class, \"Survivor\")\n isNeutral = string.match(cardMetadata.class, \"Neutral\")\n if (cardMetadata.level \u003e 0) then\n upgradeKey = \"-upgrade\"\n else\n upgradeKey = \"-level0\"\n end\n if (isGuardian) then\n table.insert(classAndLevelIndex[\"Guardian\"..upgradeKey], cardMetadata.id)\n end\n if (isSeeker) then\n table.insert(classAndLevelIndex[\"Seeker\"..upgradeKey], cardMetadata.id)\n end\n if (isMystic) then\n table.insert(classAndLevelIndex[\"Mystic\"..upgradeKey], cardMetadata.id)\n end\n if (isRogue) then\n table.insert(classAndLevelIndex[\"Rogue\"..upgradeKey], cardMetadata.id)\n end\n if (isSurvivor) then\n table.insert(classAndLevelIndex[\"Survivor\"..upgradeKey], cardMetadata.id)\n end\n if (isNeutral) then\n table.insert(classAndLevelIndex[\"Neutral\"..upgradeKey], cardMetadata.id)\n end\n\n local cycleName = cardMetadata.cycle\n if cycleName ~= nil then\n cycleName = string.lower(cycleName)\n if string.match(cycleName, \"return\") then\n cycleName = string.sub(cycleName, 11)\n end\n if cycleName == \"the night of the zealot\" then\n cycleName = \"core\"\n end\n if cycleIndex[cycleName] == nil then\n cycleIndex[cycleName] = { }\n end\n table.insert(cycleIndex[cycleName], cardMetadata.id)\n end\n end\n end\n end\n for _, indexTable in pairs(classAndLevelIndex) do\n table.sort(indexTable, cardComparator)\n end\n for _, indexTable in pairs(cycleIndex) do\n table.sort(indexTable)\n end\n table.sort(basicWeaknessList, cardComparator)\n table.sort(uniqueWeaknessList, cardComparator)\nend\n\n-- Comparison function used to sort the class card bag indexes. Sorts by card\n-- level, then name, then subname.\nfunction cardComparator(id1, id2)\n local card1 = cardIdIndex[id1]\n local card2 = cardIdIndex[id2]\n\n if (card1.metadata.level ~= card2.metadata.level) then\n return card1.metadata.level \u003c card2.metadata.level\n end\n if (card1.data.Nickname ~= card2.data.Nickname) then\n return card1.data.Nickname \u003c card2.data.Nickname\n end\n return card1.data.Description \u003c card2.data.Description\nend\n\nfunction isIndexReady()\n return indexingDone\nend\n\n-- Returns a specific card from the bag, based on ArkhamDB ID\n-- Params table:\n-- id: String ID of the card to retrieve\n-- Return: If the indexes are still being constructed, an empty table is\n-- returned. Otherwise, a single table with the following fields\n-- cardData: TTS object data, suitable for spawning the card\n-- cardMetadata: Table of parsed metadata\nfunction getCardById(params)\n if (not indexingDone) then\n broadcastToAll(\"Still loading player cards, please try again in a few seconds\", {0.9, 0.2, 0.2})\n return { }\n end\n return cardIdIndex[params.id]\nend\n\n-- Returns a list of cards from the bag matching a class and level (0 or upgraded)\n-- Params table:\n-- class: String class to retrieve (\"Guardian\", \"Seeker\", etc)\n-- isUpgraded: true for upgraded cards (Level 1-5), false for Level 0\n-- Return: If the indexes are still being constructed, returns an empty table.\n-- Otherwise, a list of tables, each with the following fields\n-- cardData: TTS object data, suitable for spawning the card\n-- cardMetadata: Table of parsed metadata\nfunction getCardsByClassAndLevel(params)\n if (not indexingDone) then\n broadcastToAll(\"Still loading player cards, please try again in a few seconds\", {0.9, 0.2, 0.2})\n return { }\n end\n local upgradeKey\n if (params.upgraded) then\n upgradeKey = \"-upgrade\"\n else\n upgradeKey = \"-level0\"\n end\n return classAndLevelIndex[params.class..upgradeKey];\nend\n\nfunction getCardsByCycle(cycleName)\n if (not indexingDone) then\n broadcastToAll(\"Still loading player cards, please try again in a few seconds\", {0.9, 0.2, 0.2})\n return { }\n end\n return cycleIndex[string.lower(cycleName)]\nend\n\n-- Searches the bag for cards which match the given name and returns a list. Note that this is\n-- an O(n) search without index support. It may be slow.\n-- Parameter array must contain these fields to define the search:\n-- name String or string fragment to search for names\n-- exact Whether the name match should be exact\nfunction getCardsByName(params)\n local name = params.name\n local exact = params.exact\n local results = { }\n -- Track cards (by ID) that we've added to avoid duplicates that may come from alternate IDs\n local addedCards = { }\n for _, cardData in pairs(cardIdIndex) do\n if (not addedCards[cardData.metadata.id]) then\n if (exact and (string.lower(cardData.data.Nickname) == string.lower(name)))\n or (not exact and string.find(string.lower(cardData.data.Nickname), string.lower(name), 1, true)) then\n table.insert(results, cardData)\n addedCards[cardData.metadata.id] = true\n end\n end\n end\n return results\nend\n\n-- Gets a random basic weakness from the bag. Once a given ID has been returned\n-- it will be removed from the list and cannot be selected again until a reload\n-- occurs or the indexes are rebuilt, which will refresh the list to include all\n-- weaknesses.\n-- Return: String ID of the selected weakness.\nfunction getRandomWeaknessId()\n local availableWeaknesses = buildAvailableWeaknesses()\n if (#availableWeaknesses \u003e 0) then\n return availableWeaknesses[math.random(#availableWeaknesses)]\n end\nend\n\n-- Constructs a list of available basic weaknesses by starting with the full pool of basic\n-- weaknesses then removing any which are currently in the play or deck construction areas\n-- Return: Table array of weakness IDs which are valid to choose from\nfunction buildAvailableWeaknesses()\n local weaknessesInPlay = { }\n local allObjects = getAllObjects()\n for _, object in ipairs(allObjects) do\n if (object.name == \"Deck\") then\n for _, cardData in ipairs(object.getData().ContainedObjects) do\n local cardMetadata = JSON.decode(cardData.GMNotes)\n incrementWeaknessCount(weaknessesInPlay, cardMetadata)\n end\n elseif (object.name == \"Card\") then\n local cardMetadata = JSON.decode(object.getGMNotes())\n incrementWeaknessCount(weaknessesInPlay, cardMetadata)\n end\n end\n\n local availableWeaknesses = { }\n for _, weaknessId in ipairs(basicWeaknessList) do\n if (weaknessesInPlay[weaknessId] ~= nil and weaknessesInPlay[weaknessId] \u003e 0) then\n weaknessesInPlay[weaknessId] = weaknessesInPlay[weaknessId] - 1\n else\n table.insert(availableWeaknesses, weaknessId)\n end\n end\n return availableWeaknesses\nend\n\nfunction getBasicWeaknesses()\n return basicWeaknessList\nend\n\nfunction getUniqueWeaknesses()\n return uniqueWeaknessList\nend\n\n-- Helper function that adds one to the table entry for the number of weaknesses in play\nfunction incrementWeaknessCount(table, cardMetadata)\n if (isBasicWeakness(cardMetadata)) then\n if (table[cardMetadata.id] == nil) then\n table[cardMetadata.id] = 1\n else\n table[cardMetadata.id] = table[cardMetadata.id] + 1\n end\n end\nend\n\nfunction isBasicWeakness(cardMetadata)\n return cardMetadata ~= nil\n and cardMetadata.weakness\n and cardMetadata.basicWeaknessCount ~= nil\n and cardMetadata.basicWeaknessCount \u003e 0\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/AllCardsBag\")\nend)\n__bundle_register(\"playercards/AllCardsBag\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal cardIdIndex = { }\nlocal classAndLevelIndex = { }\nlocal basicWeaknessList = { }\nlocal uniqueWeaknessList = { }\nlocal cycleIndex = { }\n\nlocal indexingDone = false\n\nfunction onLoad()\n self.addContextMenuItem(\"Rebuild Index\", startIndexBuild)\n math.randomseed(os.time())\n Wait.frames(startIndexBuild, 30)\nend\n\n-- Called by Hotfix bags when they load. If we are still loading indexes, then\n-- the all cards and hotfix bags are being loaded together, and we can ignore\n-- this call as the hotfix will be included in the initial indexing. If it is\n-- called once indexing is complete it means the hotfix bag has been added\n-- later, and we should rebuild the index to integrate the hotfix bag.\nfunction rebuildIndexForHotfix()\n if (indexingDone) then\n startIndexBuild()\n end\nend\n\n-- Resets all current bag indexes\nfunction clearIndexes()\n indexingDone = false\n cardIdIndex = { }\n classAndLevelIndex = { }\n classAndLevelIndex[\"Guardian-upgrade\"] = { }\n classAndLevelIndex[\"Seeker-upgrade\"] = { }\n classAndLevelIndex[\"Mystic-upgrade\"] = { }\n classAndLevelIndex[\"Survivor-upgrade\"] = { }\n classAndLevelIndex[\"Rogue-upgrade\"] = { }\n classAndLevelIndex[\"Neutral-upgrade\"] = { }\n classAndLevelIndex[\"Guardian-level0\"] = { }\n classAndLevelIndex[\"Seeker-level0\"] = { }\n classAndLevelIndex[\"Mystic-level0\"] = { }\n classAndLevelIndex[\"Survivor-level0\"] = { }\n classAndLevelIndex[\"Rogue-level0\"] = { }\n classAndLevelIndex[\"Neutral-level0\"] = { }\n cycleIndex = { }\n basicWeaknessList = { }\n uniqueWeaknessList = { }\nend\n\n-- Clears the bag indexes and starts the coroutine to rebuild the indexes\nfunction startIndexBuild()\n clearIndexes()\n startLuaCoroutine(self, \"buildIndex\")\nend\n\nfunction onObjectLeaveContainer(container, _)\n if container == self then\n broadcastToAll(\"Removing cards from the All Player Cards bag may break some functions.\", \"Red\")\n end\nend\n\n-- Create the card indexes by iterating all cards in the bag, parsing their metadata\n-- and creating the keyed lookup tables for the cards. This is a coroutine which will\n-- spread the workload by processing 20 cards before yielding.\nfunction buildIndex()\n local cardCount = 0\n indexingDone = false\n\n -- process the allcardsbag itself\n for _, cardData in ipairs(self.getData().ContainedObjects) do\n addCardToIndex(cardData)\n cardCount = cardCount + 1\n if cardCount \u003e 19 then\n cardCount = 0\n coroutine.yield(0)\n end\n end\n\n -- process hotfix bags (and the additional playercards bag)\n for _, hotfixBag in ipairs(getObjectsWithTag(\"AllCardsHotfix\")) do\n local hotfixData = hotfixBag.getData()\n if not hotfixData.ContainedObjects then break end\n\n for _, cardData in ipairs(hotfixData.ContainedObjects) do\n -- process containers\n if cardData.ContainedObjects then\n for _, deepCardData in ipairs(cardData.ContainedObjects) do\n addCardToIndex(deepCardData)\n cardCount = cardCount + 1\n if cardCount \u003e 19 then\n cardCount = 0\n coroutine.yield(0)\n end\n end\n -- process single cards\n else\n addCardToIndex(cardData)\n cardCount = cardCount + 1\n if cardCount \u003e 19 then\n cardCount = 0\n coroutine.yield(0)\n end\n end\n end\n end\n\n buildSupplementalIndexes()\n indexingDone = true\n return 1\nend\n\n-- Adds a card to any indexes it should be a part of, based on its metadata\n---@param cardData table TTS object data for the card\nfunction addCardToIndex(cardData)\n -- using the more efficient 'json.parse()' to speed this process up\n local cardMetadata = json.parse(cardData.GMNotes)\n if not cardMetadata then return end\n\n -- use the ZoopGuid as fallback if no id present\n cardIdIndex[cardMetadata.id or cardMetadata.TtsZoopGuid] = { data = cardData, metadata = cardMetadata }\n\n -- also add data for alternate ids\n if cardMetadata.alternate_ids ~= nil then\n for _, alternateId in ipairs(cardMetadata.alternate_ids) do\n cardIdIndex[alternateId] = { data = cardData, metadata = cardMetadata }\n end\n end\nend\n\nfunction buildSupplementalIndexes()\n for cardId, card in pairs(cardIdIndex) do\n local cardMetadata = card.metadata\n -- If the ID key and the metadata ID don't match this is a duplicate card created by an alternate_id, and we should skip it\n if cardId == cardMetadata.id then\n -- Add card to the basic weakness list, if appropriate. Some weaknesses have multiple copies, and are added multiple times\n if cardMetadata.weakness then\n table.insert(uniqueWeaknessList, cardMetadata.id)\n if cardMetadata.basicWeaknessCount ~= nil then\n for i = 1, cardMetadata.basicWeaknessCount do\n table.insert(basicWeaknessList, cardMetadata.id)\n end\n end\n end\n\n -- Excludes signature cards (which have no class or level)\n if cardMetadata.class ~= nil and cardMetadata.level ~= nil then\n local upgradeKey\n if cardMetadata.level \u003e 0 then\n upgradeKey = \"-upgrade\"\n else\n upgradeKey = \"-level0\"\n end\n\n -- parse classes (separated by \"|\") and add the card to the appropriate class and level indices\n for str in cardMetadata.class:gmatch(\"([^|]+)\") do\n table.insert(classAndLevelIndex[str .. upgradeKey], cardMetadata.id)\n end\n\n -- add to cycle index\n local cycleName = cardMetadata.cycle\n if cycleName ~= nil then\n cycleName = string.lower(cycleName)\n\n -- remove \"return to \" from cycle names\n cycleName = cycleName:gsub(\"return to \", \"\")\n\n -- override cycle name for night of the zealot\n cycleName = cycleName:gsub(\"the night of the zealot\", \"core\")\n\n if cycleIndex[cycleName] == nil then\n cycleIndex[cycleName] = { }\n end\n table.insert(cycleIndex[cycleName], cardMetadata.id)\n end\n end\n end\n end\n\n -- sort class and level indices\n for _, indexTable in pairs(classAndLevelIndex) do\n table.sort(indexTable, cardComparator)\n end\n\n -- sort cycle indices\n for _, indexTable in pairs(cycleIndex) do\n table.sort(indexTable)\n end\n\n -- sort weakness indices\n table.sort(basicWeaknessList, cardComparator)\n table.sort(uniqueWeaknessList, cardComparator)\nend\n\n-- Comparison function used to sort the class card bag indexes. Sorts by card level, then name, then subname.\nfunction cardComparator(id1, id2)\n local card1 = cardIdIndex[id1]\n local card2 = cardIdIndex[id2]\n\n if card1.metadata.level ~= card2.metadata.level then\n return card1.metadata.level \u003c card2.metadata.level\n elseif card1.data.Nickname ~= card2.data.Nickname then\n return card1.data.Nickname \u003c card2.data.Nickname\n else\n return card1.data.Description \u003c card2.data.Description\n end\nend\n\nfunction isIndexReady()\n return indexingDone\nend\n\n-- Returns a specific card from the bag, based on ArkhamDB ID\n-- Params table:\n-- id: String ID of the card to retrieve\n-- Return: If the indexes are still being constructed, an empty table is\n-- returned. Otherwise, a single table with the following fields\n-- cardData: TTS object data, suitable for spawning the card\n-- cardMetadata: Table of parsed metadata\nfunction getCardById(params)\n if (not indexingDone) then\n broadcastToAll(\"Still loading player cards, please try again in a few seconds\", {0.9, 0.2, 0.2})\n return { }\n end\n return cardIdIndex[params.id]\nend\n\n-- Returns a list of cards from the bag matching a class and level (0 or upgraded)\n-- Params table:\n-- class: String class to retrieve (\"Guardian\", \"Seeker\", etc)\n-- isUpgraded: true for upgraded cards (Level 1-5), false for Level 0\n-- Return: If the indexes are still being constructed, returns an empty table.\n-- Otherwise, a list of tables, each with the following fields\n-- cardData: TTS object data, suitable for spawning the card\n-- cardMetadata: Table of parsed metadata\nfunction getCardsByClassAndLevel(params)\n if (not indexingDone) then\n broadcastToAll(\"Still loading player cards, please try again in a few seconds\", {0.9, 0.2, 0.2})\n return { }\n end\n local upgradeKey\n if (params.upgraded) then\n upgradeKey = \"-upgrade\"\n else\n upgradeKey = \"-level0\"\n end\n return classAndLevelIndex[params.class..upgradeKey];\nend\n\nfunction getCardsByCycle(cycleName)\n if (not indexingDone) then\n broadcastToAll(\"Still loading player cards, please try again in a few seconds\", {0.9, 0.2, 0.2})\n return { }\n end\n return cycleIndex[string.lower(cycleName)]\nend\n\n-- Searches the bag for cards which match the given name and returns a list. Note that this is\n-- an O(n) search without index support. It may be slow.\n-- Parameter array must contain these fields to define the search:\n-- name String or string fragment to search for names\n-- exact Whether the name match should be exact\nfunction getCardsByName(params)\n local name = params.name\n local exact = params.exact\n local results = { }\n -- Track cards (by ID) that we've added to avoid duplicates that may come from alternate IDs\n local addedCards = { }\n for _, cardData in pairs(cardIdIndex) do\n if (not addedCards[cardData.metadata.id]) then\n if (exact and (string.lower(cardData.data.Nickname) == string.lower(name)))\n or (not exact and string.find(string.lower(cardData.data.Nickname), string.lower(name), 1, true)) then\n table.insert(results, cardData)\n addedCards[cardData.metadata.id] = true\n end\n end\n end\n return results\nend\n\n-- Gets a random basic weakness from the bag. Once a given ID has been returned\n-- it will be removed from the list and cannot be selected again until a reload\n-- occurs or the indexes are rebuilt, which will refresh the list to include all\n-- weaknesses.\n-- Return: String ID of the selected weakness.\nfunction getRandomWeaknessId()\n local availableWeaknesses = buildAvailableWeaknesses()\n if (#availableWeaknesses \u003e 0) then\n return availableWeaknesses[math.random(#availableWeaknesses)]\n end\nend\n\n-- Constructs a list of available basic weaknesses by starting with the full pool of basic\n-- weaknesses then removing any which are currently in the play or deck construction areas\n-- Return: Table array of weakness IDs which are valid to choose from\nfunction buildAvailableWeaknesses()\n local weaknessesInPlay = { }\n local allObjects = getAllObjects()\n for _, object in ipairs(allObjects) do\n if (object.name == \"Deck\") then\n for _, cardData in ipairs(object.getData().ContainedObjects) do\n local cardMetadata = JSON.decode(cardData.GMNotes)\n incrementWeaknessCount(weaknessesInPlay, cardMetadata)\n end\n elseif (object.name == \"Card\") then\n local cardMetadata = JSON.decode(object.getGMNotes())\n incrementWeaknessCount(weaknessesInPlay, cardMetadata)\n end\n end\n\n local availableWeaknesses = { }\n for _, weaknessId in ipairs(basicWeaknessList) do\n if (weaknessesInPlay[weaknessId] ~= nil and weaknessesInPlay[weaknessId] \u003e 0) then\n weaknessesInPlay[weaknessId] = weaknessesInPlay[weaknessId] - 1\n else\n table.insert(availableWeaknesses, weaknessId)\n end\n end\n return availableWeaknesses\nend\n\nfunction getBasicWeaknesses()\n return basicWeaknessList\nend\n\nfunction getUniqueWeaknesses()\n return uniqueWeaknessList\nend\n\n-- Helper function that adds one to the table entry for the number of weaknesses in play\nfunction incrementWeaknessCount(table, cardMetadata)\n if (isBasicWeakness(cardMetadata)) then\n if (table[cardMetadata.id] == nil) then\n table[cardMetadata.id] = 1\n else\n table[cardMetadata.id] = table[cardMetadata.id] + 1\n end\n end\nend\n\nfunction isBasicWeakness(cardMetadata)\n return cardMetadata ~= nil\n and cardMetadata.weakness\n and cardMetadata.basicWeaknessCount ~= nil\n and cardMetadata.basicWeaknessCount \u003e 0\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, @@ -194610,7 +195485,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/InvestigatorSkillTracker\")\nend)\n__bundle_register(\"playermat/InvestigatorSkillTracker\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.height = 650\nbuttonParameters.width = 700\nbuttonParameters.position = { x = -4.775, y = 0.1, z = -0.03 }\nbuttonParameters.color = { 0, 0, 0, 0 }\nbuttonParameters.font_color = { 0, 0, 0, 100 }\nbuttonParameters.font_size = 450\n\nfunction onSave() return JSON.encode(stats) end\n\n-- load stats and make buttons (left to right)\nfunction onLoad(savedData)\n stats = JSON.decode(savedData) or { 1, 1, 1, 1 }\n\n for index = 1, 4 do\n local fnName = \"buttonClick\" .. index\n _G[fnName] = function(_, _, isRightClick) buttonClick(isRightClick, index) end\n buttonParameters.click_function = fnName\n buttonParameters.position.x = buttonParameters.position.x + 1.91\n self.createButton(buttonParameters)\n updateButtonLabel(index)\n end\n\n self.addContextMenuItem(\"Reset to 1s\", function() updateStats({ 1, 1, 1, 1 }) end)\nend\n\nfunction buttonClick(isRightClick, index)\n stats[index] = math.min(math.max(stats[index] + (isRightClick and -1 or 1), 0), 99)\n updateButtonLabel(index)\nend\n\n-- sync the button label to the internal value\nfunction updateButtonLabel(index)\n local fontSize = buttonParameters.font_size\n local whitespace = \" \"\n\n if stats[index] \u003e 9 then\n fontSize = buttonParameters.font_size * 0.65\n whitespace = \" \"\n end\n\n self.editButton({ index = index - 1, label = stats[index] .. whitespace, font_size = fontSize })\nend\n\n-- update the stats to the provided values\n---@param newStats table Contains the new values for the stats: {Willpower, Intellect, Fight, Agility}\nfunction updateStats(newStats)\n if newStats and #newStats == 4 then\n stats = newStats\n\n for i = 1, 4 do updateButtonLabel(i) end\n elseif newStats then\n printToAll(\"Provided new stats are incomplete or incorrectly formatted.\", \"Red\")\n end\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playermat/InvestigatorSkillTracker\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.height = 650\nbuttonParameters.width = 700\nbuttonParameters.position = { x = -4.775, y = 0.1, z = -0.03 }\nbuttonParameters.color = { 0, 0, 0, 0 }\nbuttonParameters.font_color = { 0, 0, 0, 100 }\nbuttonParameters.font_size = 450\n\nfunction onSave() return JSON.encode(stats) end\n\n-- load stats and make buttons (left to right)\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n stats = JSON.decode(savedData) or { 1, 1, 1, 1 }\n end\n\n for index = 1, 4 do\n local fnName = \"buttonClick\" .. index\n _G[fnName] = function(_, _, isRightClick) buttonClick(isRightClick, index) end\n buttonParameters.click_function = fnName\n buttonParameters.position.x = buttonParameters.position.x + 1.91\n self.createButton(buttonParameters)\n updateButtonLabel(index)\n end\n\n self.addContextMenuItem(\"Reset to 1s\", function() updateStats({ 1, 1, 1, 1 }) end)\nend\n\nfunction buttonClick(isRightClick, index)\n stats[index] = math.min(math.max(stats[index] + (isRightClick and -1 or 1), 0), 99)\n updateButtonLabel(index)\nend\n\n-- sync the button label to the internal value\nfunction updateButtonLabel(index)\n local fontSize = buttonParameters.font_size\n local whitespace = \" \"\n\n if stats[index] \u003e 9 then\n fontSize = buttonParameters.font_size * 0.65\n whitespace = \" \"\n end\n\n self.editButton({ index = index - 1, label = stats[index] .. whitespace, font_size = fontSize })\nend\n\n-- update the stats to the provided values\n---@param newStats table Contains the new values for the stats: {Willpower, Intellect, Fight, Agility}\nfunction updateStats(newStats)\n if newStats and #newStats == 4 then\n stats = newStats\n\n for i = 1, 4 do updateButtonLabel(i) end\n elseif newStats then\n printToAll(\"Provided new stats are incomplete or incorrectly formatted.\", \"Red\")\n end\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/InvestigatorSkillTracker\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[1,1,1,1]", "MeasureMovement": false, "Name": "Custom_Token", @@ -194671,7 +195546,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/InvestigatorSkillTracker\")\nend)\n__bundle_register(\"playermat/InvestigatorSkillTracker\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.height = 650\nbuttonParameters.width = 700\nbuttonParameters.position = { x = -4.775, y = 0.1, z = -0.03 }\nbuttonParameters.color = { 0, 0, 0, 0 }\nbuttonParameters.font_color = { 0, 0, 0, 100 }\nbuttonParameters.font_size = 450\n\nfunction onSave() return JSON.encode(stats) end\n\n-- load stats and make buttons (left to right)\nfunction onLoad(savedData)\n stats = JSON.decode(savedData) or { 1, 1, 1, 1 }\n\n for index = 1, 4 do\n local fnName = \"buttonClick\" .. index\n _G[fnName] = function(_, _, isRightClick) buttonClick(isRightClick, index) end\n buttonParameters.click_function = fnName\n buttonParameters.position.x = buttonParameters.position.x + 1.91\n self.createButton(buttonParameters)\n updateButtonLabel(index)\n end\n\n self.addContextMenuItem(\"Reset to 1s\", function() updateStats({ 1, 1, 1, 1 }) end)\nend\n\nfunction buttonClick(isRightClick, index)\n stats[index] = math.min(math.max(stats[index] + (isRightClick and -1 or 1), 0), 99)\n updateButtonLabel(index)\nend\n\n-- sync the button label to the internal value\nfunction updateButtonLabel(index)\n local fontSize = buttonParameters.font_size\n local whitespace = \" \"\n\n if stats[index] \u003e 9 then\n fontSize = buttonParameters.font_size * 0.65\n whitespace = \" \"\n end\n\n self.editButton({ index = index - 1, label = stats[index] .. whitespace, font_size = fontSize })\nend\n\n-- update the stats to the provided values\n---@param newStats table Contains the new values for the stats: {Willpower, Intellect, Fight, Agility}\nfunction updateStats(newStats)\n if newStats and #newStats == 4 then\n stats = newStats\n\n for i = 1, 4 do updateButtonLabel(i) end\n elseif newStats then\n printToAll(\"Provided new stats are incomplete or incorrectly formatted.\", \"Red\")\n end\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/InvestigatorSkillTracker\")\nend)\n__bundle_register(\"playermat/InvestigatorSkillTracker\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.height = 650\nbuttonParameters.width = 700\nbuttonParameters.position = { x = -4.775, y = 0.1, z = -0.03 }\nbuttonParameters.color = { 0, 0, 0, 0 }\nbuttonParameters.font_color = { 0, 0, 0, 100 }\nbuttonParameters.font_size = 450\n\nfunction onSave() return JSON.encode(stats) end\n\n-- load stats and make buttons (left to right)\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n stats = JSON.decode(savedData) or { 1, 1, 1, 1 }\n end\n\n for index = 1, 4 do\n local fnName = \"buttonClick\" .. index\n _G[fnName] = function(_, _, isRightClick) buttonClick(isRightClick, index) end\n buttonParameters.click_function = fnName\n buttonParameters.position.x = buttonParameters.position.x + 1.91\n self.createButton(buttonParameters)\n updateButtonLabel(index)\n end\n\n self.addContextMenuItem(\"Reset to 1s\", function() updateStats({ 1, 1, 1, 1 }) end)\nend\n\nfunction buttonClick(isRightClick, index)\n stats[index] = math.min(math.max(stats[index] + (isRightClick and -1 or 1), 0), 99)\n updateButtonLabel(index)\nend\n\n-- sync the button label to the internal value\nfunction updateButtonLabel(index)\n local fontSize = buttonParameters.font_size\n local whitespace = \" \"\n\n if stats[index] \u003e 9 then\n fontSize = buttonParameters.font_size * 0.65\n whitespace = \" \"\n end\n\n self.editButton({ index = index - 1, label = stats[index] .. whitespace, font_size = fontSize })\nend\n\n-- update the stats to the provided values\n---@param newStats table Contains the new values for the stats: {Willpower, Intellect, Fight, Agility}\nfunction updateStats(newStats)\n if newStats and #newStats == 4 then\n stats = newStats\n\n for i = 1, 4 do updateButtonLabel(i) end\n elseif newStats then\n printToAll(\"Provided new stats are incomplete or incorrectly formatted.\", \"Red\")\n end\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[1,1,1,1]", "MeasureMovement": false, "Name": "Custom_Token", @@ -194732,7 +195607,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/InvestigatorSkillTracker\")\nend)\n__bundle_register(\"playermat/InvestigatorSkillTracker\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.height = 650\nbuttonParameters.width = 700\nbuttonParameters.position = { x = -4.775, y = 0.1, z = -0.03 }\nbuttonParameters.color = { 0, 0, 0, 0 }\nbuttonParameters.font_color = { 0, 0, 0, 100 }\nbuttonParameters.font_size = 450\n\nfunction onSave() return JSON.encode(stats) end\n\n-- load stats and make buttons (left to right)\nfunction onLoad(savedData)\n stats = JSON.decode(savedData) or { 1, 1, 1, 1 }\n\n for index = 1, 4 do\n local fnName = \"buttonClick\" .. index\n _G[fnName] = function(_, _, isRightClick) buttonClick(isRightClick, index) end\n buttonParameters.click_function = fnName\n buttonParameters.position.x = buttonParameters.position.x + 1.91\n self.createButton(buttonParameters)\n updateButtonLabel(index)\n end\n\n self.addContextMenuItem(\"Reset to 1s\", function() updateStats({ 1, 1, 1, 1 }) end)\nend\n\nfunction buttonClick(isRightClick, index)\n stats[index] = math.min(math.max(stats[index] + (isRightClick and -1 or 1), 0), 99)\n updateButtonLabel(index)\nend\n\n-- sync the button label to the internal value\nfunction updateButtonLabel(index)\n local fontSize = buttonParameters.font_size\n local whitespace = \" \"\n\n if stats[index] \u003e 9 then\n fontSize = buttonParameters.font_size * 0.65\n whitespace = \" \"\n end\n\n self.editButton({ index = index - 1, label = stats[index] .. whitespace, font_size = fontSize })\nend\n\n-- update the stats to the provided values\n---@param newStats table Contains the new values for the stats: {Willpower, Intellect, Fight, Agility}\nfunction updateStats(newStats)\n if newStats and #newStats == 4 then\n stats = newStats\n\n for i = 1, 4 do updateButtonLabel(i) end\n elseif newStats then\n printToAll(\"Provided new stats are incomplete or incorrectly formatted.\", \"Red\")\n end\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/InvestigatorSkillTracker\")\nend)\n__bundle_register(\"playermat/InvestigatorSkillTracker\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.height = 650\nbuttonParameters.width = 700\nbuttonParameters.position = { x = -4.775, y = 0.1, z = -0.03 }\nbuttonParameters.color = { 0, 0, 0, 0 }\nbuttonParameters.font_color = { 0, 0, 0, 100 }\nbuttonParameters.font_size = 450\n\nfunction onSave() return JSON.encode(stats) end\n\n-- load stats and make buttons (left to right)\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n stats = JSON.decode(savedData) or { 1, 1, 1, 1 }\n end\n\n for index = 1, 4 do\n local fnName = \"buttonClick\" .. index\n _G[fnName] = function(_, _, isRightClick) buttonClick(isRightClick, index) end\n buttonParameters.click_function = fnName\n buttonParameters.position.x = buttonParameters.position.x + 1.91\n self.createButton(buttonParameters)\n updateButtonLabel(index)\n end\n\n self.addContextMenuItem(\"Reset to 1s\", function() updateStats({ 1, 1, 1, 1 }) end)\nend\n\nfunction buttonClick(isRightClick, index)\n stats[index] = math.min(math.max(stats[index] + (isRightClick and -1 or 1), 0), 99)\n updateButtonLabel(index)\nend\n\n-- sync the button label to the internal value\nfunction updateButtonLabel(index)\n local fontSize = buttonParameters.font_size\n local whitespace = \" \"\n\n if stats[index] \u003e 9 then\n fontSize = buttonParameters.font_size * 0.65\n whitespace = \" \"\n end\n\n self.editButton({ index = index - 1, label = stats[index] .. whitespace, font_size = fontSize })\nend\n\n-- update the stats to the provided values\n---@param newStats table Contains the new values for the stats: {Willpower, Intellect, Fight, Agility}\nfunction updateStats(newStats)\n if newStats and #newStats == 4 then\n stats = newStats\n\n for i = 1, 4 do updateButtonLabel(i) end\n elseif newStats then\n printToAll(\"Provided new stats are incomplete or incorrectly formatted.\", \"Red\")\n end\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[1,1,1,1]", "MeasureMovement": false, "Name": "Custom_Token", @@ -194793,7 +195668,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/InvestigatorSkillTracker\")\nend)\n__bundle_register(\"playermat/InvestigatorSkillTracker\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.height = 650\nbuttonParameters.width = 700\nbuttonParameters.position = { x = -4.775, y = 0.1, z = -0.03 }\nbuttonParameters.color = { 0, 0, 0, 0 }\nbuttonParameters.font_color = { 0, 0, 0, 100 }\nbuttonParameters.font_size = 450\n\nfunction onSave() return JSON.encode(stats) end\n\n-- load stats and make buttons (left to right)\nfunction onLoad(savedData)\n stats = JSON.decode(savedData) or { 1, 1, 1, 1 }\n\n for index = 1, 4 do\n local fnName = \"buttonClick\" .. index\n _G[fnName] = function(_, _, isRightClick) buttonClick(isRightClick, index) end\n buttonParameters.click_function = fnName\n buttonParameters.position.x = buttonParameters.position.x + 1.91\n self.createButton(buttonParameters)\n updateButtonLabel(index)\n end\n\n self.addContextMenuItem(\"Reset to 1s\", function() updateStats({ 1, 1, 1, 1 }) end)\nend\n\nfunction buttonClick(isRightClick, index)\n stats[index] = math.min(math.max(stats[index] + (isRightClick and -1 or 1), 0), 99)\n updateButtonLabel(index)\nend\n\n-- sync the button label to the internal value\nfunction updateButtonLabel(index)\n local fontSize = buttonParameters.font_size\n local whitespace = \" \"\n\n if stats[index] \u003e 9 then\n fontSize = buttonParameters.font_size * 0.65\n whitespace = \" \"\n end\n\n self.editButton({ index = index - 1, label = stats[index] .. whitespace, font_size = fontSize })\nend\n\n-- update the stats to the provided values\n---@param newStats table Contains the new values for the stats: {Willpower, Intellect, Fight, Agility}\nfunction updateStats(newStats)\n if newStats and #newStats == 4 then\n stats = newStats\n\n for i = 1, 4 do updateButtonLabel(i) end\n elseif newStats then\n printToAll(\"Provided new stats are incomplete or incorrectly formatted.\", \"Red\")\n end\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playermat/InvestigatorSkillTracker\")\nend)\n__bundle_register(\"playermat/InvestigatorSkillTracker\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.height = 650\nbuttonParameters.width = 700\nbuttonParameters.position = { x = -4.775, y = 0.1, z = -0.03 }\nbuttonParameters.color = { 0, 0, 0, 0 }\nbuttonParameters.font_color = { 0, 0, 0, 100 }\nbuttonParameters.font_size = 450\n\nfunction onSave() return JSON.encode(stats) end\n\n-- load stats and make buttons (left to right)\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n stats = JSON.decode(savedData) or { 1, 1, 1, 1 }\n end\n\n for index = 1, 4 do\n local fnName = \"buttonClick\" .. index\n _G[fnName] = function(_, _, isRightClick) buttonClick(isRightClick, index) end\n buttonParameters.click_function = fnName\n buttonParameters.position.x = buttonParameters.position.x + 1.91\n self.createButton(buttonParameters)\n updateButtonLabel(index)\n end\n\n self.addContextMenuItem(\"Reset to 1s\", function() updateStats({ 1, 1, 1, 1 }) end)\nend\n\nfunction buttonClick(isRightClick, index)\n stats[index] = math.min(math.max(stats[index] + (isRightClick and -1 or 1), 0), 99)\n updateButtonLabel(index)\nend\n\n-- sync the button label to the internal value\nfunction updateButtonLabel(index)\n local fontSize = buttonParameters.font_size\n local whitespace = \" \"\n\n if stats[index] \u003e 9 then\n fontSize = buttonParameters.font_size * 0.65\n whitespace = \" \"\n end\n\n self.editButton({ index = index - 1, label = stats[index] .. whitespace, font_size = fontSize })\nend\n\n-- update the stats to the provided values\n---@param newStats table Contains the new values for the stats: {Willpower, Intellect, Fight, Agility}\nfunction updateStats(newStats)\n if newStats and #newStats == 4 then\n stats = newStats\n\n for i = 1, 4 do updateButtonLabel(i) end\n elseif newStats then\n printToAll(\"Provided new stats are incomplete or incorrectly formatted.\", \"Red\")\n end\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[1,1,1,1]", "MeasureMovement": false, "Name": "Custom_Token", @@ -194863,7 +195738,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -194923,7 +195798,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/CardSearch\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/AllCardsBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local AllCardsBagApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getAllCardsBag()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"AllCardsBag\")\n end\n\n -- Returns a specific card from the bag, based on ArkhamDB ID\n ---@param id table String ID of the card to retrieve\n ---@return table table\n -- If the indexes are still being constructed, an empty table is\n -- returned. Otherwise, a single table with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardById = function(id)\n return getAllCardsBag().call(\"getCardById\", {id = id})\n end\n\n -- Gets a random basic weakness from the bag. Once a given ID has been returned\n -- it will be removed from the list and cannot be selected again until a reload\n -- occurs or the indexes are rebuilt, which will refresh the list to include all\n -- weaknesses.\n ---@return string: ID of the selected weakness.\n AllCardsBagApi.getRandomWeaknessId = function()\n return getAllCardsBag().call(\"getRandomWeaknessId\")\n end\n\n AllCardsBagApi.isIndexReady = function()\n return getAllCardsBag().call(\"isIndexReady\")\n end\n\n -- Called by Hotfix bags when they load. If we are still loading indexes, then\n -- the all cards and hotfix bags are being loaded together, and we can ignore\n -- this call as the hotfix will be included in the initial indexing. If it is\n -- called once indexing is complete it means the hotfix bag has been added\n -- later, and we should rebuild the index to integrate the hotfix bag.\n AllCardsBagApi.rebuildIndexForHotfix = function()\n return getAllCardsBag().call(\"rebuildIndexForHotfix\")\n end\n\n -- Searches the bag for cards which match the given name and returns a list. Note that this is\n -- an O(n) search without index support. It may be slow.\n ---@param name string or string fragment to search for names\n ---@param exact boolean Whether the name match should be exact\n AllCardsBagApi.getCardsByName = function(name, exact)\n return getAllCardsBag().call(\"getCardsByName\", {name = name, exact = exact})\n end\n\n AllCardsBagApi.isBagPresent = function()\n return getAllCardsBag() and true\n end\n\n -- Returns a list of cards from the bag matching a class and level (0 or upgraded)\n ---@param class string class to retrieve (\"Guardian\", \"Seeker\", etc)\n ---@param upgraded boolean true for upgraded cards (Level 1-5), false for Level 0\n ---@return table: If the indexes are still being constructed, returns an empty table.\n -- Otherwise, a list of tables, each with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded)\n return getAllCardsBag().call(\"getCardsByClassAndLevel\", {class = class, upgraded = upgraded})\n end\n\n AllCardsBagApi.getCardsByCycle = function(cycle)\n return getAllCardsBag().call(\"getCardsByCycle\", cycle)\n end\n\n AllCardsBagApi.getUniqueWeaknesses = function()\n return getAllCardsBag().call(\"getUniqueWeaknesses\")\n end\n\n return AllCardsBagApi\nend\nend)\n__bundle_register(\"playercards/CardSearch\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/PlayerCardSpawner\")\n\nlocal allCardsBagApi = require(\"playercards/AllCardsBagApi\")\n\nlocal BUTTON_LABELS = {}\nBUTTON_LABELS[\"spawn\"] = {}\nBUTTON_LABELS[\"spawn\"][true] = \"All matching cards\"\nBUTTON_LABELS[\"spawn\"][false] = \"First matching card\"\nBUTTON_LABELS[\"search\"] = {}\nBUTTON_LABELS[\"search\"][true] = \"Name equals search term\"\nBUTTON_LABELS[\"search\"][false] = \"Name contains search term\"\n\nlocal inputParameters = {}\ninputParameters.label = \"Click to enter card name\"\ninputParameters.input_function = \"input_func\"\ninputParameters.function_owner = self\ninputParameters.alignment = 2\ninputParameters.position = { x = 0, y = 0.1, z = -0.62 }\ninputParameters.width = 3750\ninputParameters.height = 380\ninputParameters.font_size = 350\ninputParameters.scale = { 0.1, 1, 0.1 }\ninputParameters.color = { 0.9, 0.7, 0.5 }\ninputParameters.font_color = { 0, 0, 0 }\n\nfunction onSave() return JSON.encode({ spawnAll, searchExact, inputParameters.value }) end\n\nfunction onLoad(savedData)\n local loadedData = JSON.decode(savedData)\n spawnAll = loadedData[1] or false\n searchExact = loadedData[2] or false\n inputParameters.value = loadedData[3] or \"\"\n self.createInput(inputParameters)\n\n -- shared parameters\n local buttonParameters = {}\n buttonParameters.function_owner = self\n buttonParameters.font_size = 180\n buttonParameters.scale = { 0.1, 1, 0.1 }\n buttonParameters.hover_color = { 0.4, 0.6, 0.8 }\n buttonParameters.color = { 0.9, 0.7, 0.5 }\n\n -- index 0: button for spawn mode\n buttonParameters.click_function = \"toggleSpawnMode\"\n buttonParameters.label = BUTTON_LABELS[\"spawn\"][spawnAll]\n buttonParameters.position = { x = 0.16, y = 0.1, z = 0.565 }\n buttonParameters.height = 375\n buttonParameters.width = 2300\n self.createButton(buttonParameters)\n\n -- index 1: button for search mode\n buttonParameters.click_function = \"toggleSearchMode\"\n buttonParameters.label = BUTTON_LABELS[\"search\"][searchExact]\n buttonParameters.position = { x = 0.16, y = 0.1, z = 0.652 }\n self.createButton(buttonParameters)\n\n -- index 2: start search\n buttonParameters.click_function = \"startSearch\"\n buttonParameters.label = \"\"\n buttonParameters.position = { x = 0, y = 0, z = 0.806 }\n buttonParameters.height = 600\n buttonParameters.width = 2800\n self.createButton(buttonParameters)\nend\n\nfunction toggleSpawnMode()\n spawnAll = not spawnAll\n self.editButton({ index = 0, label = BUTTON_LABELS[\"spawn\"][spawnAll] })\nend\n\nfunction toggleSearchMode()\n searchExact = not searchExact\n self.editButton({ index = 1, label = BUTTON_LABELS[\"search\"][searchExact] })\nend\n\n-- if \"Enter press\" (\\n) is found, start search and recreate input\nfunction input_func(_, _, input, stillEditing)\n if not stillEditing then\n inputParameters.value = input\n elseif string.find(input, \"%\\n\") ~= nil then\n inputParameters.value = input.gsub(input, \"%\\n\", \"\")\n startSearch()\n self.removeInput(0)\n self.createInput(inputParameters)\n end\nend\n\nfunction startSearch()\n if inputParameters.value == nil or string.len(inputParameters.value) == 0 then\n printToAll(\"Please enter a search string.\", \"Yellow\")\n return\n end\n\n if string.len(inputParameters.value) \u003c 3 then\n printToAll(\"Please enter a longer search string.\", \"Yellow\")\n return\n end\n\n if not allCardsBagApi.isBagPresent() then\n printToAll(\"Player card bag couldn't be found.\", \"Red\")\n return\n end\n\n -- search all objects in bag\n local cardList = allCardsBagApi.getCardsByName(inputParameters.value, searchExact)\n if cardList == nil or #cardList == 0 then\n printToAll(\"No match found.\", \"Red\")\n return\n end\n if (#cardList \u003e 100) then\n printToAll(\"Matched more than 100 cards, please try a more specific search.\", \"Yellow\")\n return\n end\n\n -- sort table by name (reverse for multiple results, because bottom card spawns first)\n table.sort(cardList, function(k1, k2) return spawnAll == (k1.data.Nickname \u003e k2.data.Nickname) end)\n\n local rot = self.getRotation()\n local pos = self.positionToWorld(Vector(0, 2, -0.08))\n Spawner.spawnCards(cardList, pos, rot, true)\nend\nend)\n__bundle_register(\"playercards/PlayerCardSpawner\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Amount to shift for the next card (zShift) or next row of cards (xShift)\n-- Note that the table rotation is weird, and the X axis is vertical while the\n-- Z axis is horizontal\nlocal SPREAD_Z_SHIFT = -2.3\nlocal SPREAD_X_SHIFT = -3.66\n\nSpawner = { }\n\n-- Spawns a list of cards at the given position/rotation. This will separate cards by size -\n-- investigator, standard, and mini, spawning them in that order with larger cards on bottom. If\n-- there are different types, the provided callback will be called once for each type as it spawns\n-- either a card or deck.\n---@param cardList table A list of Player Card data structures (data/metadata)\n---@param pos tts__Vector table where the cards should be spawned (global)\n---@param rot tts__Vector table for the orientation of the spawned cards (global)\n---@param sort boolean True if this list of cards should be sorted before spawning\n---@param callback? function Callback to be called after the card/deck spawns.\nSpawner.spawnCards = function(cardList, pos, rot, sort, callback)\n if (sort) then\n table.sort(cardList, Spawner.cardComparator)\n end\n\n local miniCards = { }\n local standardCards = { }\n local investigatorCards = { }\n\n for _, card in ipairs(cardList) do\n if (card.metadata.type == \"Investigator\") then\n table.insert(investigatorCards, card)\n elseif (card.metadata.type == \"Minicard\") then\n table.insert(miniCards, card)\n else\n table.insert(standardCards, card)\n end\n end\n -- Spawn each of the three types individually. Each Y position shift accounts for the thickness\n -- of the spawned deck\n local position = { x = pos.x, y = pos.y, z = pos.z }\n Spawner.spawn(investigatorCards, position, rot, callback)\n\n position.y = position.y + (#investigatorCards + #standardCards) * 0.07\n Spawner.spawn(standardCards, position, rot, callback)\n\n position.y = position.y + (#standardCards + #miniCards) * 0.07\n Spawner.spawn(miniCards, position, rot, callback)\nend\n\nSpawner.spawnCardSpread = function(cardList, startPos, maxCols, rot, sort, callback)\n if (sort) then\n table.sort(cardList, Spawner.cardComparator)\n end\n\n local position = { x = startPos.x, y = startPos.y, z = startPos.z }\n -- Special handle the first row if we have less than a full single row, but only if there's a\n -- reasonable max column count. Single-row spreads will send a large value for maxCols\n if maxCols \u003c 100 and #cardList \u003c maxCols then\n position.z = startPos.z + ((maxCols - #cardList) / 2 * SPREAD_Z_SHIFT)\n end\n local cardsInRow = 0\n local rows = 0\n for _, card in ipairs(cardList) do\n Spawner.spawn({ card }, position, rot, callback)\n position.z = position.z + SPREAD_Z_SHIFT\n cardsInRow = cardsInRow + 1\n if cardsInRow \u003e= maxCols then\n rows = rows + 1\n local cardsForRow = #cardList - rows * maxCols\n if cardsForRow \u003e maxCols then\n cardsForRow = maxCols\n end\n position.z = startPos.z + ((maxCols - cardsForRow) / 2 * SPREAD_Z_SHIFT)\n position.x = position.x + SPREAD_X_SHIFT\n cardsInRow = 0\n end\n end\nend\n\n-- Spawn a specific list of cards. This method is for internal use and should not be called\n-- directly, use spawnCards instead.\n---@param cardList table A list of Player Card data structures (data/metadata)\n---@param pos table Position where the cards should be spawned (global)\n---@param rot table Rotation for the orientation of the spawned cards (global)\n---@param callback? function callback to be called after the card/deck spawns.\nSpawner.spawn = function(cardList, pos, rot, callback)\n if #cardList == 0 then return end\n\n -- Spawn a single card directly\n if #cardList == 1 then\n -- handle sideways card\n if cardList[1].data.SidewaysCard then\n rot = { rot.x, rot.y - 90, rot.z }\n end\n spawnObjectData({\n data = cardList[1].data,\n position = pos,\n rotation = rot,\n callback_function = callback\n })\n return\n end\n\n -- For multiple cards, construct a deck and spawn that\n local deck = Spawner.buildDeckDataTemplate()\n\n -- Decks won't inherently scale to the cards in them. The card list being spawned should be all\n -- the same type/size by this point, so use the first card to set the size\n deck.Transform = {\n scaleX = cardList[1].data.Transform.scaleX,\n scaleY = 1,\n scaleZ = cardList[1].data.Transform.scaleZ\n }\n\n local sidewaysDeck = true\n for _, spawnCard in ipairs(cardList) do\n Spawner.addCardToDeck(deck, spawnCard.data)\n -- set sidewaysDeck to false if any card is not a sideways card\n sidewaysDeck = (sidewaysDeck and spawnCard.data.SidewaysCard)\n end\n\n -- set the alt view angle for sideways decks\n if sidewaysDeck then\n deck.AltLookAngle = { x = 0, y = 180, z = 90 }\n rot = { rot.x, rot.y - 90, rot.z }\n end\n\n spawnObjectData({\n data = deck,\n position = pos,\n rotation = rot,\n callback_function = callback\n })\nend\n\n-- Inserts a card into the given deck. This does three things:\n-- 1. Add the card's data to ContainedObjects\n-- 2. Add the card's ID (the TTS CardID, not the Arkham ID) to the deck's\n-- ID list. Note that the deck's ID list is \"DeckIDs\" even though it\n-- contains a list of card Ids\n-- 3. Extract the card's CustomDeck table and add it to the deck. The deck's\n-- \"CustomDeck\" field is a list of all CustomDecks used by cards within the\n-- deck, keyed by the DeckID and referencing the custom deck table\n---@param deck table TTS deck data structure to add to\n---@param cardData table Data for the card to be inserted\nSpawner.addCardToDeck = function(deck, cardData)\n for customDeckId, customDeckData in pairs(cardData.CustomDeck) do\n if (deck.CustomDeck[customDeckId] == nil) then\n -- CustomDeck not added to deck yet, add it\n deck.CustomDeck[customDeckId] = customDeckData\n elseif (deck.CustomDeck[customDeckId].FaceURL == customDeckData.FaceURL) then\n -- CustomDeck for this card matches the current one for the deck, do nothing\n else\n -- CustomDeck data conflict\n local newDeckId = nil\n for deckId, customDeck in pairs(deck.CustomDeck) do\n if (customDeckData.FaceURL == customDeck.FaceURL) then\n newDeckId = deckId\n end\n end\n if (newDeckId == nil) then\n -- No non-conflicting custom deck for this card, add a new one\n newDeckId = Spawner.findNextAvailableId(deck.CustomDeck, \"1000\")\n deck.CustomDeck[newDeckId] = customDeckData\n end\n -- Update the card with the new CustomDeck info\n cardData.CardID = newDeckId..string.sub(cardData.CardID, 5)\n cardData.CustomDeck[customDeckId] = nil\n cardData.CustomDeck[newDeckId] = customDeckData\n break\n end\n end\n table.insert(deck.ContainedObjects, cardData)\n table.insert(deck.DeckIDs, cardData.CardID)\nend\n\n-- Create an empty deck data table which can have cards added to it. This\n-- creates a new table on each call without using metatables or previous\n-- definitions because we can't be sure that TTS doesn't modify the structure\n---@return table deck Table containing the minimal TTS deck data structure\nSpawner.buildDeckDataTemplate = function()\n local deck = {}\n deck.Name = \"Deck\"\n\n -- Card data. DeckIDs and CustomDeck entries will be built from the cards\n deck.ContainedObjects = {}\n deck.DeckIDs = {}\n deck.CustomDeck = {}\n\n -- Transform is required, Position and Rotation will be overridden by the spawn call so can be omitted here\n deck.Transform = {\n scaleX = 1,\n scaleY = 1,\n scaleZ = 1,\n }\n\n return deck\nend\n\n-- Returns the first ID which does not exist in the given table, starting at startId and increasing\n---@param objectTable table keyed by strings which are numbers\n---@param startId string possible ID.\n---@return string id \u003e= startId\nSpawner.findNextAvailableId = function(objectTable, startId)\n local id = startId\n while (objectTable[id] ~= nil) do\n id = tostring(tonumber(id) + 1)\n end\n return id\nend\n\n-- Get the PBCN (Permanent/Bonded/Customizable/Normal) value from the given metadata.\n---@return number PBCN 1 for Permanent, 2 for Bonded or 4 for Normal. The actual values are\n-- irrelevant as they provide only grouping and the order between them doesn't matter.\nSpawner.getpbcn = function(metadata)\n if metadata.permanent then\n return 1\n elseif metadata.bonded_to ~= nil then\n return 2\n else -- Normal card\n return 3\n end\nend\n\n-- Comparison function used to sort the cards in a deck. Groups bonded or\n-- permanent cards first, then sorts within theose types by name/subname.\n-- Normal cards will sort in standard alphabetical order, while\n-- permanent/bonded/customizable will be in reverse alphabetical order.\n--\n-- Since cards spawn in the order provided by this comparator, with the first\n-- cards ending up at the bottom of a pile, this ordering will spawn in reverse\n-- alphabetical order. This presents the cards in order for non-face-down\n-- areas, and presents them in order when Searching the face-down deck.\nSpawner.cardComparator = function(card1, card2)\n local pbcn1 = Spawner.getpbcn(card1.metadata)\n local pbcn2 = Spawner.getpbcn(card2.metadata)\n if pbcn1 ~= pbcn2 then\n return pbcn1 \u003e pbcn2\n end\n if pbcn1 == 3 then\n if card1.data.Nickname ~= card2.data.Nickname then\n return card1.data.Nickname \u003c card2.data.Nickname\n end\n return card1.data.Description \u003c card2.data.Description\n else\n if card1.data.Nickname ~= card2.data.Nickname then\n return card1.data.Nickname \u003e card2.data.Nickname\n end\n return card1.data.Description \u003e card2.data.Description\n end\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/CardSearch\")\nend)\n__bundle_register(\"playercards/CardSearch\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/PlayerCardSpawner\")\n\nlocal allCardsBagApi = require(\"playercards/AllCardsBagApi\")\n\nlocal BUTTON_LABELS = {}\nBUTTON_LABELS[\"spawn\"] = {}\nBUTTON_LABELS[\"spawn\"][true] = \"All matching cards\"\nBUTTON_LABELS[\"spawn\"][false] = \"First matching card\"\nBUTTON_LABELS[\"search\"] = {}\nBUTTON_LABELS[\"search\"][true] = \"Name equals search term\"\nBUTTON_LABELS[\"search\"][false] = \"Name contains search term\"\n\nlocal inputParameters = {}\ninputParameters.label = \"Click to enter card name\"\ninputParameters.input_function = \"input_func\"\ninputParameters.function_owner = self\ninputParameters.alignment = 2\ninputParameters.position = { x = 0, y = 0.1, z = -0.62 }\ninputParameters.width = 3750\ninputParameters.height = 380\ninputParameters.font_size = 350\ninputParameters.scale = { 0.1, 1, 0.1 }\ninputParameters.color = { 0.9, 0.7, 0.5 }\ninputParameters.font_color = { 0, 0, 0 }\n\nfunction onSave() return JSON.encode({ spawnAll, searchExact, inputParameters.value }) end\n\nfunction onLoad(savedData)\n local loadedData = JSON.decode(savedData)\n spawnAll = loadedData[1] or false\n searchExact = loadedData[2] or false\n inputParameters.value = loadedData[3] or \"\"\n self.createInput(inputParameters)\n\n -- shared parameters\n local buttonParameters = {}\n buttonParameters.function_owner = self\n buttonParameters.font_size = 180\n buttonParameters.scale = { 0.1, 1, 0.1 }\n buttonParameters.hover_color = { 0.4, 0.6, 0.8 }\n buttonParameters.color = { 0.9, 0.7, 0.5 }\n\n -- index 0: button for spawn mode\n buttonParameters.click_function = \"toggleSpawnMode\"\n buttonParameters.label = BUTTON_LABELS[\"spawn\"][spawnAll]\n buttonParameters.position = { x = 0.16, y = 0.1, z = 0.565 }\n buttonParameters.height = 375\n buttonParameters.width = 2300\n self.createButton(buttonParameters)\n\n -- index 1: button for search mode\n buttonParameters.click_function = \"toggleSearchMode\"\n buttonParameters.label = BUTTON_LABELS[\"search\"][searchExact]\n buttonParameters.position = { x = 0.16, y = 0.1, z = 0.652 }\n self.createButton(buttonParameters)\n\n -- index 2: start search\n buttonParameters.click_function = \"startSearch\"\n buttonParameters.label = \"\"\n buttonParameters.position = { x = 0, y = 0, z = 0.806 }\n buttonParameters.height = 600\n buttonParameters.width = 2800\n self.createButton(buttonParameters)\nend\n\nfunction toggleSpawnMode()\n spawnAll = not spawnAll\n self.editButton({ index = 0, label = BUTTON_LABELS[\"spawn\"][spawnAll] })\nend\n\nfunction toggleSearchMode()\n searchExact = not searchExact\n self.editButton({ index = 1, label = BUTTON_LABELS[\"search\"][searchExact] })\nend\n\n-- if \"Enter press\" (\\n) is found, start search and recreate input\nfunction input_func(_, _, input, stillEditing)\n if not stillEditing then\n inputParameters.value = input\n elseif string.find(input, \"%\\n\") ~= nil then\n inputParameters.value = input.gsub(input, \"%\\n\", \"\")\n startSearch()\n self.removeInput(0)\n self.createInput(inputParameters)\n end\nend\n\nfunction startSearch()\n if inputParameters.value == nil or string.len(inputParameters.value) == 0 then\n printToAll(\"Please enter a search string.\", \"Yellow\")\n return\n end\n\n if string.len(inputParameters.value) \u003c 3 then\n printToAll(\"Please enter a longer search string.\", \"Yellow\")\n return\n end\n\n if not allCardsBagApi.isBagPresent() then\n printToAll(\"Player card bag couldn't be found.\", \"Red\")\n return\n end\n\n -- search all objects in bag\n local cardList = allCardsBagApi.getCardsByName(inputParameters.value, searchExact)\n if cardList == nil or #cardList == 0 then\n printToAll(\"No match found.\", \"Red\")\n return\n end\n if (#cardList \u003e 100) then\n printToAll(\"Matched more than 100 cards, please try a more specific search.\", \"Yellow\")\n return\n end\n\n -- sort table by name (reverse for multiple results, because bottom card spawns first)\n table.sort(cardList, function(k1, k2) return spawnAll == (k1.data.Nickname \u003e k2.data.Nickname) end)\n\n local rot = self.getRotation()\n local pos = self.positionToWorld(Vector(0, 2, -0.08))\n Spawner.spawnCards(cardList, pos, rot, true)\nend\nend)\n__bundle_register(\"playercards/AllCardsBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local AllCardsBagApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getAllCardsBag()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"AllCardsBag\")\n end\n\n -- Returns a specific card from the bag, based on ArkhamDB ID\n ---@param id table String ID of the card to retrieve\n ---@return table table\n -- If the indexes are still being constructed, an empty table is\n -- returned. Otherwise, a single table with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardById = function(id)\n return getAllCardsBag().call(\"getCardById\", {id = id})\n end\n\n -- Gets a random basic weakness from the bag. Once a given ID has been returned\n -- it will be removed from the list and cannot be selected again until a reload\n -- occurs or the indexes are rebuilt, which will refresh the list to include all\n -- weaknesses.\n ---@return string: ID of the selected weakness.\n AllCardsBagApi.getRandomWeaknessId = function()\n return getAllCardsBag().call(\"getRandomWeaknessId\")\n end\n\n AllCardsBagApi.isIndexReady = function()\n return getAllCardsBag().call(\"isIndexReady\")\n end\n\n -- Called by Hotfix bags when they load. If we are still loading indexes, then\n -- the all cards and hotfix bags are being loaded together, and we can ignore\n -- this call as the hotfix will be included in the initial indexing. If it is\n -- called once indexing is complete it means the hotfix bag has been added\n -- later, and we should rebuild the index to integrate the hotfix bag.\n AllCardsBagApi.rebuildIndexForHotfix = function()\n return getAllCardsBag().call(\"rebuildIndexForHotfix\")\n end\n\n -- Searches the bag for cards which match the given name and returns a list. Note that this is\n -- an O(n) search without index support. It may be slow.\n ---@param name string or string fragment to search for names\n ---@param exact boolean Whether the name match should be exact\n AllCardsBagApi.getCardsByName = function(name, exact)\n return getAllCardsBag().call(\"getCardsByName\", {name = name, exact = exact})\n end\n\n AllCardsBagApi.isBagPresent = function()\n return getAllCardsBag() and true\n end\n\n -- Returns a list of cards from the bag matching a class and level (0 or upgraded)\n ---@param class string class to retrieve (\"Guardian\", \"Seeker\", etc)\n ---@param upgraded boolean true for upgraded cards (Level 1-5), false for Level 0\n ---@return table: If the indexes are still being constructed, returns an empty table.\n -- Otherwise, a list of tables, each with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded)\n return getAllCardsBag().call(\"getCardsByClassAndLevel\", {class = class, upgraded = upgraded})\n end\n\n AllCardsBagApi.getCardsByCycle = function(cycle)\n return getAllCardsBag().call(\"getCardsByCycle\", cycle)\n end\n\n AllCardsBagApi.getUniqueWeaknesses = function()\n return getAllCardsBag().call(\"getUniqueWeaknesses\")\n end\n\n return AllCardsBagApi\nend\nend)\n__bundle_register(\"playercards/PlayerCardSpawner\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Amount to shift for the next card (zShift) or next row of cards (xShift)\n-- Note that the table rotation is weird, and the X axis is vertical while the\n-- Z axis is horizontal\nlocal SPREAD_Z_SHIFT = -2.3\nlocal SPREAD_X_SHIFT = -3.66\n\nSpawner = { }\n\n-- Spawns a list of cards at the given position/rotation. This will separate cards by size -\n-- investigator, standard, and mini, spawning them in that order with larger cards on bottom. If\n-- there are different types, the provided callback will be called once for each type as it spawns\n-- either a card or deck.\n---@param cardList table A list of Player Card data structures (data/metadata)\n---@param pos tts__Vector table where the cards should be spawned (global)\n---@param rot tts__Vector table for the orientation of the spawned cards (global)\n---@param sort boolean True if this list of cards should be sorted before spawning\n---@param callback? function Callback to be called after the card/deck spawns.\nSpawner.spawnCards = function(cardList, pos, rot, sort, callback)\n if (sort) then\n table.sort(cardList, Spawner.cardComparator)\n end\n\n local miniCards = { }\n local standardCards = { }\n local investigatorCards = { }\n\n for _, card in ipairs(cardList) do\n if (card.metadata.type == \"Investigator\") then\n table.insert(investigatorCards, card)\n elseif (card.metadata.type == \"Minicard\") then\n table.insert(miniCards, card)\n else\n table.insert(standardCards, card)\n end\n end\n -- Spawn each of the three types individually. Each Y position shift accounts for the thickness\n -- of the spawned deck\n local position = { x = pos.x, y = pos.y, z = pos.z }\n Spawner.spawn(investigatorCards, position, rot, callback)\n\n position.y = position.y + (#investigatorCards + #standardCards) * 0.07\n Spawner.spawn(standardCards, position, rot, callback)\n\n position.y = position.y + (#standardCards + #miniCards) * 0.07\n Spawner.spawn(miniCards, position, rot, callback)\nend\n\nSpawner.spawnCardSpread = function(cardList, startPos, maxCols, rot, sort, callback)\n if (sort) then\n table.sort(cardList, Spawner.cardComparator)\n end\n\n local position = { x = startPos.x, y = startPos.y, z = startPos.z }\n -- Special handle the first row if we have less than a full single row, but only if there's a\n -- reasonable max column count. Single-row spreads will send a large value for maxCols\n if maxCols \u003c 100 and #cardList \u003c maxCols then\n position.z = startPos.z + ((maxCols - #cardList) / 2 * SPREAD_Z_SHIFT)\n end\n local cardsInRow = 0\n local rows = 0\n for _, card in ipairs(cardList) do\n Spawner.spawn({ card }, position, rot, callback)\n position.z = position.z + SPREAD_Z_SHIFT\n cardsInRow = cardsInRow + 1\n if cardsInRow \u003e= maxCols then\n rows = rows + 1\n local cardsForRow = #cardList - rows * maxCols\n if cardsForRow \u003e maxCols then\n cardsForRow = maxCols\n end\n position.z = startPos.z + ((maxCols - cardsForRow) / 2 * SPREAD_Z_SHIFT)\n position.x = position.x + SPREAD_X_SHIFT\n cardsInRow = 0\n end\n end\nend\n\n-- Spawn a specific list of cards. This method is for internal use and should not be called\n-- directly, use spawnCards instead.\n---@param cardList table A list of Player Card data structures (data/metadata)\n---@param pos table Position where the cards should be spawned (global)\n---@param rot table Rotation for the orientation of the spawned cards (global)\n---@param callback? function callback to be called after the card/deck spawns.\nSpawner.spawn = function(cardList, pos, rot, callback)\n if #cardList == 0 then return end\n\n -- Spawn a single card directly\n if #cardList == 1 then\n -- handle sideways card\n if cardList[1].data.SidewaysCard then\n rot = { rot.x, rot.y - 90, rot.z }\n end\n spawnObjectData({\n data = cardList[1].data,\n position = pos,\n rotation = rot,\n callback_function = callback\n })\n return\n end\n\n -- For multiple cards, construct a deck and spawn that\n local deck = Spawner.buildDeckDataTemplate()\n\n -- Decks won't inherently scale to the cards in them. The card list being spawned should be all\n -- the same type/size by this point, so use the first card to set the size\n deck.Transform = {\n scaleX = cardList[1].data.Transform.scaleX,\n scaleY = 1,\n scaleZ = cardList[1].data.Transform.scaleZ\n }\n\n local sidewaysDeck = true\n for _, spawnCard in ipairs(cardList) do\n Spawner.addCardToDeck(deck, spawnCard.data)\n -- set sidewaysDeck to false if any card is not a sideways card\n sidewaysDeck = (sidewaysDeck and spawnCard.data.SidewaysCard)\n end\n\n -- set the alt view angle for sideways decks\n if sidewaysDeck then\n deck.AltLookAngle = { x = 0, y = 180, z = 90 }\n rot = { rot.x, rot.y - 90, rot.z }\n end\n\n spawnObjectData({\n data = deck,\n position = pos,\n rotation = rot,\n callback_function = callback\n })\nend\n\n-- Inserts a card into the given deck. This does three things:\n-- 1. Add the card's data to ContainedObjects\n-- 2. Add the card's ID (the TTS CardID, not the Arkham ID) to the deck's\n-- ID list. Note that the deck's ID list is \"DeckIDs\" even though it\n-- contains a list of card Ids\n-- 3. Extract the card's CustomDeck table and add it to the deck. The deck's\n-- \"CustomDeck\" field is a list of all CustomDecks used by cards within the\n-- deck, keyed by the DeckID and referencing the custom deck table\n---@param deck table TTS deck data structure to add to\n---@param cardData table Data for the card to be inserted\nSpawner.addCardToDeck = function(deck, cardData)\n for customDeckId, customDeckData in pairs(cardData.CustomDeck) do\n if (deck.CustomDeck[customDeckId] == nil) then\n -- CustomDeck not added to deck yet, add it\n deck.CustomDeck[customDeckId] = customDeckData\n elseif (deck.CustomDeck[customDeckId].FaceURL == customDeckData.FaceURL) then\n -- CustomDeck for this card matches the current one for the deck, do nothing\n else\n -- CustomDeck data conflict\n local newDeckId = nil\n for deckId, customDeck in pairs(deck.CustomDeck) do\n if (customDeckData.FaceURL == customDeck.FaceURL) then\n newDeckId = deckId\n end\n end\n if (newDeckId == nil) then\n -- No non-conflicting custom deck for this card, add a new one\n newDeckId = Spawner.findNextAvailableId(deck.CustomDeck, \"1000\")\n deck.CustomDeck[newDeckId] = customDeckData\n end\n -- Update the card with the new CustomDeck info\n cardData.CardID = newDeckId..string.sub(cardData.CardID, 5)\n cardData.CustomDeck[customDeckId] = nil\n cardData.CustomDeck[newDeckId] = customDeckData\n break\n end\n end\n table.insert(deck.ContainedObjects, cardData)\n table.insert(deck.DeckIDs, cardData.CardID)\nend\n\n-- Create an empty deck data table which can have cards added to it. This\n-- creates a new table on each call without using metatables or previous\n-- definitions because we can't be sure that TTS doesn't modify the structure\n---@return table deck Table containing the minimal TTS deck data structure\nSpawner.buildDeckDataTemplate = function()\n local deck = {}\n deck.Name = \"Deck\"\n\n -- Card data. DeckIDs and CustomDeck entries will be built from the cards\n deck.ContainedObjects = {}\n deck.DeckIDs = {}\n deck.CustomDeck = {}\n\n -- Transform is required, Position and Rotation will be overridden by the spawn call so can be omitted here\n deck.Transform = {\n scaleX = 1,\n scaleY = 1,\n scaleZ = 1,\n }\n\n return deck\nend\n\n-- Returns the first ID which does not exist in the given table, starting at startId and increasing\n---@param objectTable table keyed by strings which are numbers\n---@param startId string possible ID.\n---@return string id \u003e= startId\nSpawner.findNextAvailableId = function(objectTable, startId)\n local id = startId\n while (objectTable[id] ~= nil) do\n id = tostring(tonumber(id) + 1)\n end\n return id\nend\n\n-- Get the PBCN (Permanent/Bonded/Customizable/Normal) value from the given metadata.\n---@return number PBCN 1 for Permanent, 2 for Bonded or 4 for Normal. The actual values are\n-- irrelevant as they provide only grouping and the order between them doesn't matter.\nSpawner.getpbcn = function(metadata)\n if metadata.permanent then\n return 1\n elseif metadata.bonded_to ~= nil then\n return 2\n else -- Normal card\n return 3\n end\nend\n\n-- Comparison function used to sort the cards in a deck. Groups bonded or\n-- permanent cards first, then sorts within theose types by name/subname.\n-- Normal cards will sort in standard alphabetical order, while\n-- permanent/bonded/customizable will be in reverse alphabetical order.\n--\n-- Since cards spawn in the order provided by this comparator, with the first\n-- cards ending up at the bottom of a pile, this ordering will spawn in reverse\n-- alphabetical order. This presents the cards in order for non-face-down\n-- areas, and presents them in order when Searching the face-down deck.\nSpawner.cardComparator = function(card1, card2)\n local pbcn1 = Spawner.getpbcn(card1.metadata)\n local pbcn2 = Spawner.getpbcn(card2.metadata)\n if pbcn1 ~= pbcn2 then\n return pbcn1 \u003e pbcn2\n end\n if pbcn1 == 3 then\n if card1.data.Nickname ~= card2.data.Nickname then\n return card1.data.Nickname \u003c card2.data.Nickname\n end\n return card1.data.Description \u003c card2.data.Description\n else\n if card1.data.Nickname ~= card2.data.Nickname then\n return card1.data.Nickname \u003e card2.data.Nickname\n end\n return card1.data.Description \u003e card2.data.Description\n end\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "[true,false,\"\"]", "MeasureMovement": false, "Name": "Custom_Tile", @@ -194980,7 +195855,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/PhaseTracker\")\nend)\n__bundle_register(\"accessories/PhaseTracker\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal phaseNames = {\n \"I. Mythos Phase\",\n \"II. Investigation Phase\",\n \"III. Enemy Phase\",\n \"IV. Upkeep Phase\"\n}\nlocal phaseImages = {\n \"http://cloud-3.steamusercontent.com/ugc/933819604050849085/9E22AFD7B0157140FC177DBCCBCB1D61D6A0329F/\",\n \"http://cloud-3.steamusercontent.com/ugc/933819604050885611/845B5AA915F30492B5F34864698B9C3627FA5763/\",\n \"http://cloud-3.steamusercontent.com/ugc/982233321870235122/492996D07ABF6DDA4B605A3013C4892839DCF1F3/\",\n \"http://cloud-3.steamusercontent.com/ugc/982233321870237261/C287CAED2423970F33E72D6C7415CBEC6794C533/\"\n}\n\nfunction onSave()\n return JSON.encode({\n phaseId = phaseId,\n broadcastChange = broadcastChange\n })\nend\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n phaseId = loadedData.phaseId\n broadcastChange = loadedData.broadcastChange\n else\n phaseId = 1\n broadcastChange = false\n end\n\n self.createButton(\n {\n tooltip = \"change phase\",\n click_function = 'changeState',\n function_owner = self,\n width = 600,\n height = 600\n })\n\n self.addContextMenuItem(\"toggle broadcasting\", updateBroadcast)\nend\n\nfunction updateBroadcast()\n for _, tracker in ipairs(getObjectsWithTag(\"LinkedPhaseTracker\")) do\n tracker.setVar(\"broadcastChange\", not broadcastChange)\n end\n broadcastToAll(\"Broadcasting phase changes has been \" .. (broadcastChange and \"enabled.\" or \"disabled.\"))\nend\n\nfunction changeState(_, _, isRightClick)\n -- get newId for all trackers\n local newId = phaseId + (isRightClick and -1 or 1)\n if newId == 0 then\n newId = 4\n elseif newId == 5 then\n newId = 1\n end\n\n -- broadcast if option is enabled\n if broadcastChange then\n broadcastToAll(phaseNames[newId])\n end\n\n -- manipulate data and then respawn\n local data = self.getData()\n data[\"CustomImage\"][\"ImageURL\"] = phaseImages[newId]\n data[\"CustomImage\"][\"ImageSecondaryURL\"] = phaseImages[newId]\n data[\"LuaScriptState\"] = \"{\\\"broadcastChange\\\":\" .. tostring(broadcastChange) .. \",\\\"phaseId\\\":\" .. newId .. \"}\"\n\n -- update all trackers with tag\n for _, tracker in ipairs(getObjectsWithTag(\"LinkedPhaseTracker\")) do\n local pos = tracker.getPosition()\n local rot = tracker.getRotation()\n local scale = tracker.getScale()\n tracker.destruct()\n spawnObjectData(\n {\n data = data,\n position = pos,\n rotation = rot,\n scale = scale\n }\n )\n end\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/PhaseTracker\")\nend)\n__bundle_register(\"accessories/PhaseTracker\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal phaseNames = {\n \"I. Mythos Phase\",\n \"II. Investigation Phase\",\n \"III. Enemy Phase\",\n \"IV. Upkeep Phase\"\n}\nlocal phaseImages = {\n \"http://cloud-3.steamusercontent.com/ugc/933819604050849085/9E22AFD7B0157140FC177DBCCBCB1D61D6A0329F/\",\n \"http://cloud-3.steamusercontent.com/ugc/933819604050885611/845B5AA915F30492B5F34864698B9C3627FA5763/\",\n \"http://cloud-3.steamusercontent.com/ugc/982233321870235122/492996D07ABF6DDA4B605A3013C4892839DCF1F3/\",\n \"http://cloud-3.steamusercontent.com/ugc/982233321870237261/C287CAED2423970F33E72D6C7415CBEC6794C533/\"\n}\n\nlocal phaseId, broadcastChange\n\nfunction onSave()\n return JSON.encode({\n phaseId = phaseId,\n broadcastChange = broadcastChange\n })\nend\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n phaseId = loadedData.phaseId\n broadcastChange = loadedData.broadcastChange\n else\n phaseId = 1\n broadcastChange = false\n end\n\n self.createButton(\n {\n tooltip = \"change phase\",\n click_function = 'changeState',\n function_owner = self,\n width = 600,\n height = 600\n })\n\n self.addContextMenuItem(\"toggle broadcasting\", updateBroadcast)\nend\n\nfunction updateBroadcast()\n for _, tracker in ipairs(getObjectsWithTag(\"LinkedPhaseTracker\")) do\n tracker.setVar(\"broadcastChange\", not broadcastChange)\n end\n broadcastToAll(\"Broadcasting phase changes has been \" .. (broadcastChange and \"enabled.\" or \"disabled.\"))\nend\n\nfunction changeState(_, _, isRightClick)\n -- get newId for all trackers\n local newId = phaseId + (isRightClick and -1 or 1)\n if newId == 0 then\n newId = 4\n elseif newId == 5 then\n newId = 1\n end\n\n -- broadcast if option is enabled\n if broadcastChange then\n broadcastToAll(phaseNames[newId])\n end\n\n -- manipulate data and then respawn\n local data = self.getData()\n data[\"CustomImage\"][\"ImageURL\"] = phaseImages[newId]\n data[\"CustomImage\"][\"ImageSecondaryURL\"] = phaseImages[newId]\n data[\"LuaScriptState\"] = \"{\\\"broadcastChange\\\":\" .. tostring(broadcastChange) .. \",\\\"phaseId\\\":\" .. newId .. \"}\"\n\n -- update all trackers with tag\n for _, tracker in ipairs(getObjectsWithTag(\"LinkedPhaseTracker\")) do\n local pos = tracker.getPosition()\n local rot = tracker.getRotation()\n local scale = tracker.getScale()\n tracker.destruct()\n spawnObjectData(\n {\n data = data,\n position = pos,\n rotation = rot,\n scale = scale\n }\n )\n end\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "{\"broadcastChange\":false,\"phaseId\":1}", "MeasureMovement": false, "Name": "Custom_Tile", @@ -199422,7 +200297,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = {}\n\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n else\n position = { 0, 0.06, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/GenericCounter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nMIN_VALUE = 0\nMAX_VALUE = 99\nval = 0\n\nfunction onSave() return JSON.encode(val) end\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n val = JSON.decode(savedData)\n end\n\n local name = self.getName()\n local position = { 0, 0.06, 0 }\n\n -- set position of label depending on object\n if name == \"Damage\" or name == \"Resources\" or name == \"Resource Counter\" then\n position = { 0, 0.06, 0.1 }\n elseif name == \"Horror\" then\n position = { -0.025, 0.06, -0.025 }\n elseif name == \"Elder Sign Counter\" or name == \"Auto-fail Counter\" then\n position = { 0, 0.1, 0 }\n end\n\n self.createButton({\n label = tostring(val),\n click_function = \"addOrSubtract\",\n function_owner = self,\n position = position,\n height = 600,\n width = 1000,\n scale = { 1.5, 1.5, 1.5 },\n font_size = 600,\n font_color = { 1, 1, 1, 100 },\n color = { 0, 0, 0, 0 }\n })\n\n -- add context menu entries\n self.addContextMenuItem(\"Add 5\", function() updateVal(val + 5) end)\n self.addContextMenuItem(\"Subtract 5\", function() updateVal(val - 5) end)\n self.addContextMenuItem(\"Add 10\", function() updateVal(val + 10) end)\n self.addContextMenuItem(\"Subtract 10\", function() updateVal(val - 10) end)\nend\n\nfunction updateVal(newVal)\n if tonumber(newVal) then\n val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\n end\nend\n\nfunction addOrSubtract(_, _, isRightClick)\n val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)\n self.editButton({ index = 0, label = tostring(val) })\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GenericCounter\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "0", "MeasureMovement": false, "Memo": "resourceCounter", @@ -199444,6 +200319,2291 @@ }, "Value": 0, "XmlUI": "" + }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.24706, + "g": 0.24706, + "r": 0.24706 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355435567056295/5A6DE2C637AADCD147723211020D8C0D0591EAE7/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120440/08045D95997033A4D64764850FC2B68C4FB12A3C/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "04765c", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Memo": "actionToken", + "Name": "Custom_Tile", + "Nickname": "Neutral", + "Snap": true, + "States": { + "1": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.647058845, + "g": 0.3294117, + "r": 0.07450976 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524115513/9CA3B804F167041F03C9E0687378FF7B5DCDE1B8/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524115014/6CBF573A12494524613C6280F558D4BED97CF007/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "0bcce1", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Guardian", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -53.1985855, + "posY": 1.55004013, + "posZ": -22.5279942, + "rotX": 359.983826, + "rotY": 269.989624, + "rotZ": 359.9841, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "10": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.2117644, + "g": 0.2823527, + "r": 0.06666646 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120675/493ACE1FA05ED4DC96CC7F6D85B3488378C15DD2/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120736/F53989F0806C796D180647A16C6BB4E9957F6DBF/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "68f249", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Rogue Engage/Fight Action", + "Snap": true, + "States": { + "1": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.647058845, + "g": 0.329411745, + "r": 0.07450979 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524115513/9CA3B804F167041F03C9E0687378FF7B5DCDE1B8/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524115014/6CBF573A12494524613C6280F558D4BED97CF007/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "e4b2b6", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Guardian", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.242507, + "posY": 0.959991634, + "posZ": -3.66628647, + "rotX": 3.19422554e-7, + "rotY": 269.987976, + "rotZ": -0.00009157829, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "11": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.2117644, + "g": 0.2823527, + "r": 0.06666646 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524119623/2244A30B5EBB4126F0BE1D2FF61F6C824DFEE58D/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524119692/042FBF813801CFDF4FEDA9ED3205D331842975FA/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "befce9", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Evade Action", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -8.970487, + "posY": 0.959991634, + "posZ": -5.93830156, + "rotX": -0.0000076235865, + "rotY": 269.9841, + "rotZ": -0.000118024727, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "12": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.2117644, + "g": 0.2823527, + "r": 0.06666646 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120530/79626D1941BEE2D2A310FD4B7C8E3CE90E6820AB/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120607/0D0F1B80B4E6A20B4728F1F7582FF09C1D4A3B9F/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "b439e3", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Parley Action", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -8.970486, + "posY": 0.959991634, + "posZ": -7.074313, + "rotX": 0.0000133775629, + "rotY": 269.988464, + "rotZ": -0.0000981453049, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "13": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.380391777, + "g": 0.07058794, + "r": 0.321568251 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524121068/E62DCFA57CE5FE6AF021A2F07C6650323BE19C93/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524121138/A5506FADCE917AA99925516A147E0320322B5BDD/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "f72f18", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Spell Action", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -7.834444, + "posY": 0.9599933, + "posZ": -3.666303, + "rotX": -0.0000930833849, + "rotY": 269.979767, + "rotZ": -0.0000140167895, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "14": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.176470339, + "g": 0.117646806, + "r": 0.745098054 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524119758/EE686A3287D3399347AD72140474F599585E68D5/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524119839/A92D5AF13B283117BD62EE84B657A3A71FBBD274/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "bbd286", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Play Item Action", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -7.83447456, + "posY": 0.9599919, + "posZ": -4.80229, + "rotX": -0.0000181347659, + "rotY": 269.9885, + "rotZ": -0.000124786486, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "15": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 1, + "g": 1, + "r": 1 + }, + "CustomMesh": { + "CastShadows": true, + "ColliderURL": "", + "Convex": true, + "DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/952965722516201848/72B3B9E2B59F25FEC82412AC22245D03655A4558/", + "MaterialIndex": 3, + "MeshURL": "https://pastebin.com/raw/ALrYhQGb", + "NormalURL": "", + "TypeIndex": 4 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "11508f", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Model", + "Nickname": "Guardian", + "Snap": true, + "Sticky": true, + "Tooltip": true, + "Transform": { + "posX": -7.83447456, + "posY": 1.019994, + "posZ": -5.93830156, + "rotX": 0.00007209413, + "rotY": 269.988525, + "rotZ": 0.0000200837931, + "scaleX": 0.45, + "scaleY": 0.6, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "16": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 1, + "g": 1, + "r": 1 + }, + "CustomMesh": { + "CastShadows": true, + "ColliderURL": "", + "Convex": true, + "DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/952965722516265983/F50A6212D30C442429ED22B8CC8FD24D4CB76A2A/", + "MaterialIndex": 3, + "MeshURL": "https://pastebin.com/raw/ALrYhQGb", + "NormalURL": "", + "TypeIndex": 4 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "8888ff", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Model", + "Nickname": "Seeker", + "Snap": true, + "Sticky": true, + "Tooltip": true, + "Transform": { + "posX": -7.834475, + "posY": 1.01999056, + "posZ": -7.074312, + "rotX": -0.00008478706, + "rotY": 270.009827, + "rotZ": -0.00007123187, + "scaleX": 0.45, + "scaleY": 0.6, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "17": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 1, + "g": 1, + "r": 1 + }, + "CustomMesh": { + "CastShadows": true, + "ColliderURL": "", + "Convex": true, + "DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/952965722515898740/E92441671B056D4CDF99DF9E6C88BE6598AAB50F/", + "MaterialIndex": 3, + "MeshURL": "https://pastebin.com/raw/ALrYhQGb", + "NormalURL": "", + "TypeIndex": 4 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "7f001b", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Model", + "Nickname": "Rogue", + "Snap": true, + "Sticky": true, + "Tooltip": true, + "Transform": { + "posX": -6.698466, + "posY": 1.01999128, + "posZ": -3.66628671, + "rotX": 0.00007766587, + "rotY": 270.000031, + "rotZ": 0.000128919462, + "scaleX": 0.45, + "scaleY": 0.6, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "18": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 1, + "g": 1, + "r": 1 + }, + "CustomMesh": { + "CastShadows": true, + "ColliderURL": "", + "Convex": true, + "DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/952965722516557267/757887224F6C37104CDFFE241FAD09B57117D670/", + "MaterialIndex": 3, + "MeshURL": "https://pastebin.com/raw/ALrYhQGb", + "NormalURL": "", + "TypeIndex": 4 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "6bd479", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Model", + "Nickname": "Mystic", + "Snap": true, + "Sticky": true, + "Tooltip": true, + "Transform": { + "posX": -6.69846535, + "posY": 1.019991, + "posZ": -4.80229, + "rotX": 0.0000896203055, + "rotY": 269.999969, + "rotZ": 0.000128821237, + "scaleX": 0.45, + "scaleY": 0.6, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "19": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 1, + "g": 1, + "r": 1 + }, + "CustomMesh": { + "CastShadows": true, + "ColliderURL": "", + "Convex": true, + "DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/952965722515960460/F43F63452854B10B416FDF3BF9EF3068E6E68F26/", + "MaterialIndex": 3, + "MeshURL": "https://pastebin.com/raw/ALrYhQGb", + "NormalURL": "", + "TypeIndex": 4 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "172d0e", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Model", + "Nickname": "Survivor", + "Snap": true, + "Sticky": true, + "Tooltip": true, + "Transform": { + "posX": -6.69846535, + "posY": 1.01999176, + "posZ": -5.938301, + "rotX": 0.000100863988, + "rotY": 270.000061, + "rotZ": 0.0000739920142, + "scaleX": 0.45, + "scaleY": 0.6, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "2": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.290195674, + "g": 0.5803921, + "r": 0.894117653 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120939/5A99D70BBAA96A7CCE94CBAA01BC8C9352F59174/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524121002/727C40B7A122B3EC91AD1EF76741A9888E1FF0FF/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "45b80c", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Seeker", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.2425117, + "posY": 0.959991634, + "posZ": -3.66628766, + "rotX": -0.00000112005034, + "rotY": 269.987976, + "rotZ": -0.00009159232, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "20": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 1, + "g": 1, + "r": 1 + }, + "CustomMesh": { + "CastShadows": true, + "ColliderURL": "", + "Convex": true, + "DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/950722873599303195/BAB8BB40C755C099128931212969243EFF56ED39/", + "MaterialIndex": 3, + "MeshURL": "https://pastebin.com/raw/ALrYhQGb", + "NormalURL": "", + "TypeIndex": 4 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "2d0664", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Model", + "Nickname": "Neutral", + "Snap": true, + "Sticky": true, + "Tooltip": true, + "Transform": { + "posX": -6.698465, + "posY": 1.01999319, + "posZ": -7.07431269, + "rotX": 0.00007148875, + "rotY": 270.000122, + "rotZ": 0.00009776296, + "scaleX": 0.45, + "scaleY": 0.6, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "3": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.211764365, + "g": 0.282352656, + "r": 0.06666643 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120799/1AA70B46183E3DC9981CD93D0A289D456C368B15/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120870/FFA52250CDBE4067D16226E7B4C8D2E6BF263C5B/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "6cd9a4", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Rogue", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.2425175, + "posY": 0.959991634, + "posZ": -3.66628838, + "rotX": -0.0000136311965, + "rotY": 269.987885, + "rotZ": -0.00010959358, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "4": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.380391747, + "g": 0.07058791, + "r": 0.321568221 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120230/08DDB68E10023CC76B9450989F3526F9744A9F77/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120299/D6B1AAFF9763CD6F410D56A716D731714DE34EF8/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "484748", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Mystic", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.2425222, + "posY": 0.959991634, + "posZ": -3.66628933, + "rotX": -0.0000148262206, + "rotY": 269.987854, + "rotZ": -0.000109348286, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "5": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.176470309, + "g": 0.117646776, + "r": 0.745098054 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524121217/CBDB66CA029638728CE27CCBD335BDCFF25B6BCE/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524121301/8A83B84C4EC594D48259904616769E84C5191F83/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "59124e", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Survivor", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.242528, + "posY": 0.959991634, + "posZ": -3.66629028, + "rotX": -0.0000209040336, + "rotY": 269.9878, + "rotZ": -0.000119170043, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "6": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.247059911, + "g": 0.247059911, + "r": 0.247059911 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355435567056295/5A6DE2C637AADCD147723211020D8C0D0591EAE7/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120440/08045D95997033A4D64764850FC2B68C4FB12A3C/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "2691e1", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Neutral", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.2425337, + "posY": 0.959991634, + "posZ": -3.66629124, + "rotX": -0.0000184208129, + "rotY": 269.9878, + "rotZ": -0.000116128736, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "7": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.647058845, + "g": 0.3294117, + "r": 0.07450976 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524119903/366BC6E113AE8B9BE480617CEC6BE564CF37CE93/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524119975/196A6AB09BE31462712BA7DF6F6698762B3FC98D/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "29d645", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Guardian Engage/Fight Action", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.2425385, + "posY": 0.959991634, + "posZ": -3.66629219, + "rotX": -0.0000287290841, + "rotY": 269.9878, + "rotZ": -0.000127649575, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "8": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.290195674, + "g": 0.5803921, + "r": 0.894117653 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120070/74F06CA8602C110158A32ADFF9E1FC1FB858612B/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120154/9E0936305F807390EBA6AB130E498BFEDBA7596C/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "85047f", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Investigate Action", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.2425432, + "posY": 0.959991634, + "posZ": -3.66629314, + "rotX": -0.0000293503817, + "rotY": 269.987823, + "rotZ": -0.000127514912, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "9": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.290195674, + "g": 0.5803921, + "r": 0.894117653 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524121381/43FEB2F56E57A5B72E6E7F02E138539D5BB42AC1/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524121455/F21B46B06BBF327601B4F8A5F9F00974149A6752/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "2c6c38", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Tome Action", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.2425489, + "posY": 0.959991634, + "posZ": -3.66629434, + "rotX": -0.0000277218132, + "rotY": 269.987732, + "rotZ": -0.000125872859, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + } + }, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.2425489, + "posY": 0.959991634, + "posZ": -3.66629434, + "rotX": -0.0000277218132, + "rotY": 269.987732, + "rotZ": -0.000125872859, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "11": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.2117644, + "g": 0.2823527, + "r": 0.06666646 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524119623/2244A30B5EBB4126F0BE1D2FF61F6C824DFEE58D/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524119692/042FBF813801CFDF4FEDA9ED3205D331842975FA/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "befce9", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Evade Action", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -8.970487, + "posY": 0.959991634, + "posZ": -5.93830156, + "rotX": -0.0000076235865, + "rotY": 269.9841, + "rotZ": -0.000118024727, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "12": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.2117644, + "g": 0.2823527, + "r": 0.06666646 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120530/79626D1941BEE2D2A310FD4B7C8E3CE90E6820AB/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120607/0D0F1B80B4E6A20B4728F1F7582FF09C1D4A3B9F/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "b439e3", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Parley Action", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -8.970486, + "posY": 0.959991634, + "posZ": -7.074313, + "rotX": 0.0000133775629, + "rotY": 269.988464, + "rotZ": -0.0000981453049, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "13": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.380391777, + "g": 0.07058794, + "r": 0.321568251 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524121068/E62DCFA57CE5FE6AF021A2F07C6650323BE19C93/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524121138/A5506FADCE917AA99925516A147E0320322B5BDD/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "f72f18", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Spell Action", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -7.834444, + "posY": 0.9599933, + "posZ": -3.666303, + "rotX": -0.0000930833849, + "rotY": 269.979767, + "rotZ": -0.0000140167895, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "14": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.176470339, + "g": 0.117646806, + "r": 0.745098054 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524119758/EE686A3287D3399347AD72140474F599585E68D5/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524119839/A92D5AF13B283117BD62EE84B657A3A71FBBD274/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "bbd286", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Play Item Action", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -7.83447456, + "posY": 0.9599919, + "posZ": -4.80229, + "rotX": -0.0000181347659, + "rotY": 269.9885, + "rotZ": -0.000124786486, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "15": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 1, + "g": 1, + "r": 1 + }, + "CustomMesh": { + "CastShadows": true, + "ColliderURL": "", + "Convex": true, + "DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/952965722516201848/72B3B9E2B59F25FEC82412AC22245D03655A4558/", + "MaterialIndex": 3, + "MeshURL": "https://pastebin.com/raw/ALrYhQGb", + "NormalURL": "", + "TypeIndex": 4 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "11508f", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Model", + "Nickname": "Guardian", + "Snap": true, + "Sticky": true, + "Tooltip": true, + "Transform": { + "posX": -7.83447456, + "posY": 1.019994, + "posZ": -5.93830156, + "rotX": 0.00007209413, + "rotY": 269.988525, + "rotZ": 0.0000200837931, + "scaleX": 0.45, + "scaleY": 0.6, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "16": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 1, + "g": 1, + "r": 1 + }, + "CustomMesh": { + "CastShadows": true, + "ColliderURL": "", + "Convex": true, + "DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/952965722516265983/F50A6212D30C442429ED22B8CC8FD24D4CB76A2A/", + "MaterialIndex": 3, + "MeshURL": "https://pastebin.com/raw/ALrYhQGb", + "NormalURL": "", + "TypeIndex": 4 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "8888ff", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Model", + "Nickname": "Seeker", + "Snap": true, + "Sticky": true, + "Tooltip": true, + "Transform": { + "posX": -7.834475, + "posY": 1.01999056, + "posZ": -7.074312, + "rotX": -0.00008478706, + "rotY": 270.009827, + "rotZ": -0.00007123187, + "scaleX": 0.45, + "scaleY": 0.6, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "17": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 1, + "g": 1, + "r": 1 + }, + "CustomMesh": { + "CastShadows": true, + "ColliderURL": "", + "Convex": true, + "DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/952965722515898740/E92441671B056D4CDF99DF9E6C88BE6598AAB50F/", + "MaterialIndex": 3, + "MeshURL": "https://pastebin.com/raw/ALrYhQGb", + "NormalURL": "", + "TypeIndex": 4 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "7f001b", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Model", + "Nickname": "Rogue", + "Snap": true, + "Sticky": true, + "Tooltip": true, + "Transform": { + "posX": -6.698466, + "posY": 1.01999128, + "posZ": -3.66628671, + "rotX": 0.00007766587, + "rotY": 270.000031, + "rotZ": 0.000128919462, + "scaleX": 0.45, + "scaleY": 0.6, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "18": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 1, + "g": 1, + "r": 1 + }, + "CustomMesh": { + "CastShadows": true, + "ColliderURL": "", + "Convex": true, + "DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/952965722516557267/757887224F6C37104CDFFE241FAD09B57117D670/", + "MaterialIndex": 3, + "MeshURL": "https://pastebin.com/raw/ALrYhQGb", + "NormalURL": "", + "TypeIndex": 4 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "6bd479", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Model", + "Nickname": "Mystic", + "Snap": true, + "Sticky": true, + "Tooltip": true, + "Transform": { + "posX": -6.69846535, + "posY": 1.019991, + "posZ": -4.80229, + "rotX": 0.0000896203055, + "rotY": 269.999969, + "rotZ": 0.000128821237, + "scaleX": 0.45, + "scaleY": 0.6, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "19": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 1, + "g": 1, + "r": 1 + }, + "CustomMesh": { + "CastShadows": true, + "ColliderURL": "", + "Convex": true, + "DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/952965722515960460/F43F63452854B10B416FDF3BF9EF3068E6E68F26/", + "MaterialIndex": 3, + "MeshURL": "https://pastebin.com/raw/ALrYhQGb", + "NormalURL": "", + "TypeIndex": 4 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "172d0e", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Model", + "Nickname": "Survivor", + "Snap": true, + "Sticky": true, + "Tooltip": true, + "Transform": { + "posX": -6.69846535, + "posY": 1.01999176, + "posZ": -5.938301, + "rotX": 0.000100863988, + "rotY": 270.000061, + "rotZ": 0.0000739920142, + "scaleX": 0.45, + "scaleY": 0.6, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "2": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.290195674, + "g": 0.5803921, + "r": 0.894117653 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120939/5A99D70BBAA96A7CCE94CBAA01BC8C9352F59174/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524121002/727C40B7A122B3EC91AD1EF76741A9888E1FF0FF/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "45b80c", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Seeker", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.2425117, + "posY": 0.959991634, + "posZ": -3.66628766, + "rotX": -0.00000112005034, + "rotY": 269.987976, + "rotZ": -0.00009159232, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "20": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 1, + "g": 1, + "r": 1 + }, + "CustomMesh": { + "CastShadows": true, + "ColliderURL": "", + "Convex": true, + "DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/950722873599303195/BAB8BB40C755C099128931212969243EFF56ED39/", + "MaterialIndex": 3, + "MeshURL": "https://pastebin.com/raw/ALrYhQGb", + "NormalURL": "", + "TypeIndex": 4 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "2d0664", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Model", + "Nickname": "Neutral", + "Snap": true, + "Sticky": true, + "Tooltip": true, + "Transform": { + "posX": -6.698465, + "posY": 1.01999319, + "posZ": -7.07431269, + "rotX": 0.00007148875, + "rotY": 270.000122, + "rotZ": 0.00009776296, + "scaleX": 0.45, + "scaleY": 0.6, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "3": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.211764365, + "g": 0.282352656, + "r": 0.06666643 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120799/1AA70B46183E3DC9981CD93D0A289D456C368B15/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120870/FFA52250CDBE4067D16226E7B4C8D2E6BF263C5B/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "6cd9a4", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Rogue", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.2425175, + "posY": 0.959991634, + "posZ": -3.66628838, + "rotX": -0.0000136311965, + "rotY": 269.987885, + "rotZ": -0.00010959358, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "4": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.380391747, + "g": 0.07058791, + "r": 0.321568221 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120230/08DDB68E10023CC76B9450989F3526F9744A9F77/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120299/D6B1AAFF9763CD6F410D56A716D731714DE34EF8/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "484748", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Mystic", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.2425222, + "posY": 0.959991634, + "posZ": -3.66628933, + "rotX": -0.0000148262206, + "rotY": 269.987854, + "rotZ": -0.000109348286, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "5": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.176470309, + "g": 0.117646776, + "r": 0.745098054 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524121217/CBDB66CA029638728CE27CCBD335BDCFF25B6BCE/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524121301/8A83B84C4EC594D48259904616769E84C5191F83/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "59124e", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Survivor", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.242528, + "posY": 0.959991634, + "posZ": -3.66629028, + "rotX": -0.0000209040336, + "rotY": 269.9878, + "rotZ": -0.000119170043, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "7": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.647058845, + "g": 0.3294117, + "r": 0.07450976 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524119903/366BC6E113AE8B9BE480617CEC6BE564CF37CE93/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524119975/196A6AB09BE31462712BA7DF6F6698762B3FC98D/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "29d645", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Guardian Engage/Fight Action", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.2425385, + "posY": 0.959991634, + "posZ": -3.66629219, + "rotX": -0.0000287290841, + "rotY": 269.9878, + "rotZ": -0.000127649575, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "8": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.290195674, + "g": 0.5803921, + "r": 0.894117653 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120070/74F06CA8602C110158A32ADFF9E1FC1FB858612B/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524120154/9E0936305F807390EBA6AB130E498BFEDBA7596C/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "85047f", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Investigate Action", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.2425432, + "posY": 0.959991634, + "posZ": -3.66629314, + "rotX": -0.0000293503817, + "rotY": 269.987823, + "rotZ": -0.000127514912, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + }, + "9": { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.290195644, + "g": 0.5803921, + "r": 0.894117653 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 2 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524121381/43FEB2F56E57A5B72E6E7F02E138539D5BB42AC1/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037355191524121455/F21B46B06BBF327601B4F8A5F9F00974149A6752/", + "WidthScale": 0 + }, + "Description": "Action Token", + "DragSelectable": true, + "GMNotes": "", + "GUID": "2c6c38", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Tome Action", + "Snap": true, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -11.2425547, + "posY": 0.959991634, + "posZ": -3.66629553, + "rotX": -0.0000261616078, + "rotY": 269.987671, + "rotZ": -0.00012405579, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" + } + }, + "Sticky": true, + "Tags": [ + "ActionToken" + ], + "Tooltip": true, + "Transform": { + "posX": -53.2, + "posY": 1.55, + "posZ": 9.67, + "rotX": 0, + "rotY": 270, + "rotZ": 0, + "scaleX": 0.45, + "scaleY": 1, + "scaleZ": 0.45 + }, + "Value": 0, + "XmlUI": "" } ], "Description": "", @@ -199566,7 +202726,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/tour/TourStarter\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/tour/TourCard\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Table definition for the tour card layout. This is functionally XMLUI in Lua form, but using\n-- this for dynamic creation ensures we can handle any player color without needing 10\n-- near-duplicate definitions in Global.xml\n\ntourCardTemplate = {\n tag = \"Panel\",\n attributes = {\n id = \"tourCard\",\n height = 215,\n width = 330,\n rotation = \"0 0 0\",\n position = \"0 300 30\",\n showAnimation = \"FadeIn\",\n hideAnimation = \"FadeOut\",\n active = false\n },\n children = {\n {\n tag = \"Image\",\n attributes = {\n id = \"tourNarratorImageLeft\",\n height = 120,\n width = 80,\n rectAlignment = \"UpperLeft\",\n offsetXY = \"-80 0\"\n -- Image will be set when the card is updated\n }\n },\n {\n tag = \"Image\",\n attributes = {\n id = \"tourNarratorImageRight\",\n active = false,\n height = 125,\n width = 80,\n rectAlignment = \"UpperRight\",\n offsetXY = \"80 0\"\n -- Image will be set when the card is updated\n }\n },\n {\n tag = \"Image\",\n attributes = {\n id = \"tourSpeechBubble\",\n color = \"#F5F5DC\",\n height = 215,\n width = 330,\n rectAlignment = \"MiddleCenter\",\n image = \"SpeechBubble\"\n }\n },\n {\n tag = \"Text\",\n attributes = {\n id = \"tourText\",\n -- Everything on this is double-sized and scaled down to keep the text sharps\n height = 370,\n width = 520,\n scale = \"0.5 0.5 1\",\n rectAlignment = \"UpperCenter\",\n offsetXY = \"15 -15\",\n resizeTextForBestFit = true,\n resizeTextMinSize = 20,\n resizeTextMaxSize = 32,\n color = \"#050505\",\n alignment = \"UpperLeft\",\n horizontalOverflow = \"wrap\"\n }\n },\n {\n tag = \"Image\",\n attributes = {\n id = \"tourNext\",\n height = 45,\n width = 45,\n rectAlignment = \"LowerRight\",\n offsetXY = \"-5 -45\",\n image = \"NextArrow\"\n }\n },\n {\n tag = \"Image\",\n attributes = {\n id = \"tourStop\",\n height = 45,\n width = 45,\n rectAlignment = \"LowerLeft\",\n offsetXY = \"35 -45\",\n image = \"Exit\"\n }\n }\n }\n}\nend)\n__bundle_register(\"core/tour/TourManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n require(\"core/tour/TourScript\")\n require(\"core/tour/TourCard\")\n local TourManager = {}\n local internal = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- Base IDs for various tour card UI elements. Actual IDs will have _[playerColor] appended\n local CARD_ID = \"tourCard\"\n local LEFT_NARRATOR_ID = \"tourNarratorImageLeft\"\n local RIGHT_NARRATOR_ID = \"tourNarratorImageRight\"\n local BUBBLE_ID = \"tourSpeechBubble\"\n local TEXT_ID = \"tourText\"\n local NEXT_BUTTON_ID = \"tourNext\"\n local STOP_BUTTON_ID = \"tourStop\"\n\n -- Table centerpoint for the camera hook object. Camera handling is a bit erratic so it doesn't\n -- always land right where you think it's going to, but it's close\n local HOOK_CAMERA_HOME = {\n x = -30.2,\n y = 60,\n z = 0,\n }\n\n -- Default (0) position for the camera, as defined in the mod. If we don't recreate this position\n -- EXACTLY when exiting the tour then camera controls get weird\n local DEFAULT_CAMERA_POS = {\n position = { x = -22.26, y = -2.5, z = 5.26 },\n pitch = 64.34,\n yaw = 90,\n distance = 104\n }\n\n -- Global XML coordinates where we can present a card\n local SCREEN_POSITIONS = {\n center = \"0 0 0\",\n north = \"0 300 0\",\n east = \"600 0 0\",\n west = \"-600 0 0\",\n south = \"0 -300 0\",\n\n -- Northwest is only used by the Mandy card, move it a little right than standard so it's\n -- closer to the importer\n northwest = \"-500 300 0\",\n northeast = \"600 300 0\",\n southwest = \"-600 -300 0\",\n\n -- Used by the Diana and Wini cards referencing the bottom-right global controls, moved a little\n -- closer to them\n southeast = \"730 -365 0\"\n }\n\n -- Tracks the current state of the tours. Keyed by player color to keep each player's tour\n -- separate, will hold the camera hook and current card.\n local tourState = {}\n\n -- Kicks off the tour by initializing the card and camera hook. A callback on the hook creation\n -- will then show the first card.\n ---@param playerColor string Player color to start the tour for\n TourManager.startTour = function(playerColor)\n tourState[playerColor] = {\n currentCardIndex = 1\n }\n -- Camera gets really screwy when we finalize if we don't start settled in ThirdPerson at the\n -- default position before attaching to the hook. Unfortunately there are no callbacks for when\n -- the movement is done, but the delay seems to handle it\n Player[playerColor].setCameraMode(\"ThirdPerson\")\n Player[playerColor].lookAt(DEFAULT_CAMERA_POS)\n\n -- Initial camera rotation is painfully slow. White and Orange players are likely oriented\n -- correctly, but need a longer start delay for Green and Red\n local delay = 0.5\n if playerColor ~= \"White\" and playerColor ~= \"Orange\" then\n delay = 2\n broadcastToColor(\"Starting the tour, please wait...\", playerColor)\n end\n Wait.time(function()\n internal.createTourCard(playerColor)\n -- XML update to add the new card takes a few frames to load, wait for it to finish then create the hook\n Wait.condition(function() internal.createCameraHook(playerColor) end, function() return not Global.UI.loading end)\n end, delay)\n end\n\n -- Shows the next card in the tour script. This method is exposed (rather than being part of\n -- internal) because the XMLUI callbacks expect the method to be on the object directly.\n ---@param player tts__Player object to show the next card for, provided by XMLUI callback\n function nextCard(player)\n internal.hideCard(player.color)\n Wait.time(function()\n tourState[player.color].currentCardIndex = tourState[player.color].currentCardIndex + 1\n if tourState[player.color].currentCardIndex \u003e #TOUR_SCRIPT then\n internal.finalizeTour(player.color)\n else\n internal.showCurrentCard(player.color)\n end\n end, 0.3)\n end\n\n -- Ends the tour and cleans up the camera. This method is exposed (rather than being part of\n -- internal) because the XMLUI callbacks expect the method to be on the object directly.\n ---@param player tts__Player object to end the tour for, provided by XMLUI callback\n function stopTour(player)\n internal.hideCard(player.color)\n Wait.time(function()\n internal.finalizeTour(player.color)\n end, 0.3)\n end\n\n -- Updates the card UI for the script at the current index, moves the camera to the proper\n -- position, and shows the card.\n ---@param playerColor string Player color to show the current card for\n internal.showCurrentCard = function(playerColor)\n internal.updateCardDisplay(playerColor)\n local delay = 0\n local cardIndex = tourState[playerColor].currentCardIndex\n local hook = getObjectFromGUID(tourState[playerColor].cameraHookGuid)\n\n if not TOUR_SCRIPT[cardIndex].skipCentering then\n hook.setPositionSmooth(HOOK_CAMERA_HOME, false, false)\n delay = delay + 0.5\n end\n local lookPos\n local objReferenceData = TOUR_SCRIPT[cardIndex].objReferenceData\n if objReferenceData ~= nil then\n local lookAtObj = guidReferenceApi.getObjectByOwnerAndType(objReferenceData.owner, objReferenceData.type)\n lookPos = lookAtObj.getPosition()\n lookPos.y = TOUR_SCRIPT[cardIndex].distanceFromObj or 0\n -- Since camera isn't directly above the hook, changing the Y affects the visual position of\n -- whatever object we're trying to look at. This is an approximation, but close enough to\n -- keep the object more centered\n lookPos.x = lookPos.x - lookPos.y / 2\n elseif TOUR_SCRIPT[cardIndex].showPos ~= nil then\n lookPos = TOUR_SCRIPT[cardIndex].showPos\n end\n if lookPos ~= nil then\n Wait.time(function()\n hook.setPositionSmooth(lookPos, false, false)\n end, delay)\n delay = delay + 0.5\n end\n Wait.time(function() Global.UI.show(internal.getUiId(CARD_ID, playerColor)) end, delay)\n end\n\n -- Hides the current card being shown to a player. This can be in preparation for showing the\n -- next card, or ending the tour.\n ---@param playerColor string Player color to hide the current card for\n internal.hideCard = function(playerColor)\n Global.UI.hide(internal.getUiId(CARD_ID, playerColor))\n end\n\n -- Cleans up all the various resources associated with the tour, and (hopefully) resets the\n -- camera to the default position. Camera handling is erratic, the final card in the script\n -- should include instructions for the player to fix it.\n ---@param playerColor string Player color to clean up\n internal.finalizeTour = function(playerColor)\n local cameraHook = getObjectFromGUID(tourState[playerColor].cameraHookGuid)\n cameraHook.destruct()\n Player[playerColor].setCameraMode(\"ThirdPerson\")\n tourState[playerColor] = nil\n Wait.frames(function()\n Player[playerColor].lookAt(DEFAULT_CAMERA_POS)\n end, 3)\n end\n\n -- Updates the card UI to show the appropriate card configuration.\n ---@param playerColor string Player color to update card for\n internal.updateCardDisplay = function(playerColor)\n local index = tourState[playerColor].currentCardIndex\n Global.UI.setAttribute(internal.getUiId(LEFT_NARRATOR_ID, playerColor), \"image\", \"Inv-\" .. TOUR_SCRIPT[index].narrator)\n Global.UI.setAttribute(internal.getUiId(RIGHT_NARRATOR_ID, playerColor), \"image\", \"Inv-\" .. TOUR_SCRIPT[index].narrator)\n Global.UI.setAttribute(internal.getUiId(TEXT_ID, playerColor), \"text\", \"\\\"\" .. TOUR_SCRIPT[index].text .. \"\\\"\")\n local cardPos = TOUR_SCRIPT[index].position or \"north\"\n Global.UI.setAttribute(internal.getUiId(CARD_ID, playerColor), \"position\", SCREEN_POSITIONS[cardPos])\n Global.UI.setAttribute(internal.getUiId(NEXT_BUTTON_ID, playerColor), \"active\", index \u003c #TOUR_SCRIPT)\n\n -- Adjust images so the narrator is on the left or right, as defined by the card\n if TOUR_SCRIPT[index].speakerSide == \"right\" then\n Global.UI.setAttribute(internal.getUiId(LEFT_NARRATOR_ID, playerColor), \"active\", false)\n Global.UI.setAttribute(internal.getUiId(RIGHT_NARRATOR_ID, playerColor), \"active\", true)\n Global.UI.setAttribute(internal.getUiId(BUBBLE_ID, playerColor), \"rotation\", \"0 180 0\")\n Global.UI.setAttribute(internal.getUiId(TEXT_ID, playerColor), \"offsetXY\", \"-15 -15\")\n Global.UI.setAttribute(internal.getUiId(NEXT_BUTTON_ID, playerColor), \"offsetXY\", \"-35 -45\")\n Global.UI.setAttribute(internal.getUiId(STOP_BUTTON_ID, playerColor), \"offsetXY\", \"5 -45\")\n else\n Global.UI.setAttribute(internal.getUiId(LEFT_NARRATOR_ID, playerColor), \"active\", true)\n Global.UI.setAttribute(internal.getUiId(RIGHT_NARRATOR_ID, playerColor), \"active\", false)\n Global.UI.setAttribute(internal.getUiId(BUBBLE_ID, playerColor), \"rotation\", \"0 0 0\")\n Global.UI.setAttribute(internal.getUiId(TEXT_ID, playerColor), \"offsetXY\", \"15 -15\")\n Global.UI.setAttribute(internal.getUiId(NEXT_BUTTON_ID, playerColor), \"offsetXY\", \"-5 -45\")\n Global.UI.setAttribute(internal.getUiId(STOP_BUTTON_ID, playerColor), \"offsetXY\", \"35 -45\")\n end\n end\n\n -- Creates a small, transparent object which the camera will be attached to in order to move the\n -- user's view around the table. This should be called only at the beginning of the tour. Once\n -- creation is complete the user's camera will be attached to the hook and the first card will be\n -- shown.\n ---@param playerColor string Player color to create the hook for\n internal.createCameraHook = function(playerColor)\n local hookData = {\n Name = \"BlockSquare\",\n Transform = {\n posX = HOOK_CAMERA_HOME.x,\n posY = HOOK_CAMERA_HOME.y,\n posZ = HOOK_CAMERA_HOME.z,\n rotX = 0,\n rotY = 270,\n rotZ = 0,\n scaleX = 0.1,\n scaleY = 0.1,\n scaleZ = 0.1,\n },\n ColorDiffuse = {\n r = 0,\n g = 0,\n b = 0,\n a = 0,\n },\n Locked = true,\n GMNotes = playerColor\n }\n\n spawnObjectData({ data = hookData, callback_function = internal.onHookCreated })\n end\n\n -- Callback for creation of the camera hook object. Will attach the camera and show the current\n -- (presumably first) card.\n ---@param hook tts__Object Created object\n internal.onHookCreated = function(hook)\n local playerColor = hook.getGMNotes()\n tourState[playerColor].cameraHookGuid = hook.getGUID()\n Player[playerColor].attachCameraToObject({\n object = hook,\n offset = { x = -20, y = 30, z = 0 }\n })\n internal.showCurrentCard(playerColor)\n end\n\n -- Creates an XMLUI entry in Global for a player-specific tour card. Dynamically creating this\n -- is somewhat complex, but ensures we can properly handle any player color.\n ---@param playerColor string Player color to create the card for\n internal.createTourCard = function(playerColor)\n -- Make sure the card doesn't exist before we create a new one\n if Global.UI.getAttributes(internal.getUiId(CARD_ID, playerColor)) ~= nil then return end\n \n tourCardTemplate.attributes.id = internal.getUiId(CARD_ID, playerColor)\n tourCardTemplate.children[1].attributes.id = internal.getUiId(LEFT_NARRATOR_ID, playerColor)\n tourCardTemplate.children[2].attributes.id = internal.getUiId(RIGHT_NARRATOR_ID, playerColor)\n tourCardTemplate.children[3].attributes.id = internal.getUiId(BUBBLE_ID, playerColor)\n tourCardTemplate.children[4].attributes.id = internal.getUiId(TEXT_ID, playerColor)\n tourCardTemplate.children[5].attributes.id = internal.getUiId(NEXT_BUTTON_ID, playerColor)\n tourCardTemplate.children[5].attributes.onClick = self.getGUID() .. \"/nextCard\"\n tourCardTemplate.children[6].attributes.id = internal.getUiId(STOP_BUTTON_ID, playerColor)\n tourCardTemplate.children[6].attributes.onClick = self.getGUID() .. \"/stopTour\"\n internal.setDeepVisibility(tourCardTemplate, playerColor)\n\n local globalXml = Global.UI.getXmlTable()\n table.insert(globalXml, tourCardTemplate)\n Global.UI.setXmlTable(globalXml)\n end\n\n -- Panels don't cause their children to inherit their visibility value, so this recurses down the\n -- XML table to set all children to the same visibility.\n ---@param xmlUi table Lua table describing the XML\n ---@param playerColor string String color of the player to make this visible for\n internal.setDeepVisibility = function(xmlUi, playerColor)\n xmlUi.attributes.visibility = \"\" .. playerColor\n if xmlUi.children ~= nil then\n for _, child in ipairs(xmlUi.children) do\n internal.setDeepVisibility(child, playerColor)\n end\n end\n end\n\n internal.getUiId = function(baseId, playerColor)\n return baseId .. \"_\" .. playerColor\n end\n\n return TourManager\nend\nend)\n__bundle_register(\"core/tour/TourScript\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Script for the SCED tour. Documentation and definitions to come.\n\nTOUR_SCRIPT = {\n {\n narrator = \"Roland\",\n text = \"Despite my best efforts, looks like you found us. You may live to regret that. As long as you're here though we might as well show you around.\\n\\nUse the arrow to move forward, and if the horrors get to be too much you can quit whenever you like. Ready to get started?\",\n position = \"center\"\n },\n {\n narrator = \"Darrell\",\n text = \"Cameras can be tricky things. Best you leave handling it to the professionals during the tour. Don't try to move the camera until the tour is complete.\\n\\nOnce we're done, remember you can use the 'p' key to switch back to third-person mode, and the spacebar to reset the position.\",\n position = \"center\",\n speakerSide = \"right\"\n },\n {\n narrator = \"Daisy\",\n text = \"If you're new to the game, the library here has everything you'll need. A little research can go a long way, and looking into old newspapers for the weird and unusual can yield some surprisingly helpful information.\\n\\nI put a few right there that might prove enlightening.\",\n objReferenceData = { owner = \"Mythos\", type = \"RulesReference\" },\n distanceFromObj = 20,\n position = \"west\",\n speakerSide = \"right\"\n },\n {\n narrator = \"Mandy\",\n text = \"To survive what's coming you'll need a deck. If it's safely hidden away on ArkhamDB you can load it here, and even find the newest version after an upgrade without changing the ID.\\n\\nNo need to publish all your decks, use 'Private' and you can see it. Just make sure to select 'Make your decks public' in ArkhamDB.\",\n objReferenceData = { owner = \"Mythos\", type = \"DeckImporter\" },\n distanceFromObj = -5,\n position = \"northwest\",\n skipCentering = true\n },\n {\n narrator = \"Daniela\",\n text = \"I prefer the hands-on approach to building things, if you do too you can build a deck yourself.\\n\\nAll the cards you could ever need are here, laid out like a disassembled engine. Place the cards on the table, copy them for your deck, and you'll be ready for anything.\",\n objReferenceData = { owner = \"Mythos\", type = \"PlayerCardPanel\" },\n distanceFromObj = -7,\n position = \"south\",\n speakerSide = \"right\"\n },\n {\n narrator = \"Finn\",\n text = \"Ready to face the unknown? We've smuggled shocking revelations and devious enemies from all over the world. Download the campaign you want to play, then Place it on the table to see the scenarios.\\n\\nJust remember - if it turns out to be too much for you, I was never here.\",\n objReferenceData = { owner = \"Mythos\", type = \"CampaignThePathToCarcosa\" },\n distanceFromObj = 20,\n position = \"northwest\",\n skipCentering = true\n },\n {\n narrator = \"Diana\",\n text = \"These symbols on the bottom right are a repository of arcane knowledge, containing all the official content to download plus some deviously creative works from fans. One should beware those who seem too fond of the darkness, but you cannot deny the quality of their efforts.\\n\\nDon't see anything here? Only promoted players can access these.\",\n position = \"southeast\"\n },\n {\n narrator = \"Winifred\",\n text = \"No good aviator would fly a plane she didn't know and hadn't tweaked a bit herself. The gear icon contains settings to customize your play experience, from alternate ways to track your clues to a variety of helpers to streamline the game.\\n\\nEverything here is optional, but who doesn't want to go as fast as they can? Just remember that all settings affect all players, so strap in and trust your pilot!\",\n position = \"southeast\"\n },\n {\n narrator = \"Amina\",\n text = \"This is the Mythos area. Encounter cards, acts, and agenda will all be placed here while the large map below is where you will be exploring - be sure to set the number of investigators!\\n\\nYou can count doom on the agenda by clicking the large counter, and the smaller will automatically count doom tokens on the table. The chaos bag is in that book over on the right, and you can add or remove tokens from it whenever you need.\",\n showPos = { x = -2.85, y = 0, z = 0.55 },\n position = \"north\",\n speakerSide = \"right\"\n },\n {\n narrator = \"Gloria\",\n text = \"The evils that lurk in this world are out there, creeping ever closer. When they find you, this will easily draw a card from the encounter deck. The deck will even reshuffle itself when needed, for the enemies we face are unending.\",\n showPos = { x = -35, y = -20, z = 28 },\n position = \"west\",\n skipCentering = true\n },\n {\n narrator = \"Jacqueline\",\n text = \"When the ire of fate finds you and the chaos looms, this large button will draw a chaos token. Click it again to return the token to the bag.\\n\\nWhether a vision of the future or a curse from the opponents we face, if you need additional tokens a right-click will draw more. I wish you luck, but have a vision of red tentacles reaching for you...\",\n showPos = { x = -35, y = -20, z = 4.25 },\n position = \"north\",\n skipCentering = true,\n speakerSide = \"right\"\n },\n {\n narrator = \"Kohaku\",\n text = \"Folklorists, immersed in the rich narratives of blessings and curses, explore the essence of human beliefs. You can use this tool to control the amount of bless and curse tokens in the chaos bag. It will also display the amount in the bag (+ sealed on cards) for you. Remember to remove bless / curse tokens with this after resolving them.\",\n objReferenceData = { owner = \"Mythos\", type = \"BlessCurseManager\" },\n position = \"center\",\n skipCentering = true,\n speakerSide = \"left\"\n },\n {\n narrator = \"Preston\",\n text = \"I can afford to buy what I need, but for those less well-off we've provided an endless pool of tokens to track your game. Simply drag one out of the pools here.\\n\\nResources are my favorite of course, but damage and horror are as inevitable as taxes. I leave those to my bookkeeper though. Those tokens can work like counters, use the number keys to change the value.\",\n objReferenceData = { owner = \"Mythos\", type = \"ResourceTokenBag\" },\n position = \"north\",\n skipCentering = true,\n speakerSide = \"right\"\n },\n {\n narrator = \"Norman\",\n text = \"That's the end of the tour, but there's much more to discover if you look in the right places. Some cards have helpers on the right-click menu, and every new version adds new content and functions.\\n\\nDon't be afraid to explore, and best of luck out there! We'll all need it...\",\n position = \"center\",\n speakerSide = \"right\"\n }\n}\nend)\n__bundle_register(\"core/tour/TourStarter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal tourManager = require(\"core/tour/TourManager\")\n\nfunction onLoad()\n self.createButton({\n click_function = \"startTour\",\n function_owner = self,\n position = { 1.27, 0.05, 0.035},\n width = 500,\n height = 20,\n color = { 0, 0, 0, 0 },\n -- TTS has a minium height for buttons, have to scale the Z-axis down to get the right size\n scale = { 1, 1, 0.82 },\n tooltip = \"Start the Tour\",\n })\n self.createButton({\n click_function = \"deleteStarter\",\n function_owner = self,\n position = { 1.27, 0.05, 0.309},\n width = 500,\n height = 20,\n color = { 0, 0, 0, 0 },\n -- TTS has a minium height for buttons, have to scale the Z-axis down to get the right size\n scale = { 1, 1, 0.82 },\n tooltip = \"Delete this Panel\",\n })\nend\n\nfunction startTour(_, playerColor, _)\n tourManager.startTour(playerColor)\nend\n\nfunction deleteStarter(_, _, _)\n self.destruct()\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/tour/TourManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n require(\"core/tour/TourScript\")\n require(\"core/tour/TourCard\")\n local TourManager = {}\n local internal = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- Base IDs for various tour card UI elements. Actual IDs will have _[playerColor] appended\n local CARD_ID = \"tourCard\"\n local LEFT_NARRATOR_ID = \"tourNarratorImageLeft\"\n local RIGHT_NARRATOR_ID = \"tourNarratorImageRight\"\n local BUBBLE_ID = \"tourSpeechBubble\"\n local TEXT_ID = \"tourText\"\n local NEXT_BUTTON_ID = \"tourNext\"\n local STOP_BUTTON_ID = \"tourStop\"\n\n -- Table centerpoint for the camera hook object. Camera handling is a bit erratic so it doesn't\n -- always land right where you think it's going to, but it's close\n local HOOK_CAMERA_HOME = {\n x = -30.2,\n y = 60,\n z = 0,\n }\n\n -- Default (0) position for the camera, as defined in the mod. If we don't recreate this position\n -- EXACTLY when exiting the tour then camera controls get weird\n local DEFAULT_CAMERA_POS = {\n position = { x = -22.26, y = -2.5, z = 5.26 },\n pitch = 64.34,\n yaw = 90,\n distance = 104\n }\n\n -- Global XML coordinates where we can present a card\n local SCREEN_POSITIONS = {\n center = \"0 0 0\",\n north = \"0 300 0\",\n east = \"600 0 0\",\n west = \"-600 0 0\",\n south = \"0 -300 0\",\n\n -- Northwest is only used by the Mandy card, move it a little right than standard so it's\n -- closer to the importer\n northwest = \"-500 300 0\",\n northeast = \"600 300 0\",\n southwest = \"-600 -300 0\",\n\n -- Used by the Diana and Wini cards referencing the bottom-right global controls, moved a little\n -- closer to them\n southeast = \"730 -365 0\"\n }\n\n -- Tracks the current state of the tours. Keyed by player color to keep each player's tour\n -- separate, will hold the camera hook and current card.\n local tourState = {}\n\n -- Kicks off the tour by initializing the card and camera hook. A callback on the hook creation\n -- will then show the first card.\n ---@param playerColor string Player color to start the tour for\n TourManager.startTour = function(playerColor)\n tourState[playerColor] = {\n currentCardIndex = 1\n }\n -- Camera gets really screwy when we finalize if we don't start settled in ThirdPerson at the\n -- default position before attaching to the hook. Unfortunately there are no callbacks for when\n -- the movement is done, but the delay seems to handle it\n Player[playerColor].setCameraMode(\"ThirdPerson\")\n Player[playerColor].lookAt(DEFAULT_CAMERA_POS)\n\n -- Initial camera rotation is painfully slow. White and Orange players are likely oriented\n -- correctly, but need a longer start delay for Green and Red\n local delay = 0.5\n if playerColor ~= \"White\" and playerColor ~= \"Orange\" then\n delay = 2\n broadcastToColor(\"Starting the tour, please wait...\", playerColor)\n end\n Wait.time(function()\n internal.createTourCard(playerColor)\n -- XML update to add the new card takes a few frames to load, wait for it to finish then create the hook\n Wait.condition(function() internal.createCameraHook(playerColor) end, function() return not Global.UI.loading end)\n end, delay)\n end\n\n -- Shows the next card in the tour script. This method is exposed (rather than being part of\n -- internal) because the XMLUI callbacks expect the method to be on the object directly.\n ---@param player tts__Player object to show the next card for, provided by XMLUI callback\n function nextCard(player)\n internal.hideCard(player.color)\n Wait.time(function()\n tourState[player.color].currentCardIndex = tourState[player.color].currentCardIndex + 1\n if tourState[player.color].currentCardIndex \u003e #TOUR_SCRIPT then\n internal.finalizeTour(player.color)\n else\n internal.showCurrentCard(player.color)\n end\n end, 0.3)\n end\n\n -- Ends the tour and cleans up the camera. This method is exposed (rather than being part of\n -- internal) because the XMLUI callbacks expect the method to be on the object directly.\n ---@param player tts__Player object to end the tour for, provided by XMLUI callback\n function stopTour(player)\n internal.hideCard(player.color)\n Wait.time(function()\n internal.finalizeTour(player.color)\n end, 0.3)\n end\n\n -- Updates the card UI for the script at the current index, moves the camera to the proper\n -- position, and shows the card.\n ---@param playerColor string Player color to show the current card for\n internal.showCurrentCard = function(playerColor)\n internal.updateCardDisplay(playerColor)\n local delay = 0\n local cardIndex = tourState[playerColor].currentCardIndex\n local hook = getObjectFromGUID(tourState[playerColor].cameraHookGuid)\n\n if not TOUR_SCRIPT[cardIndex].skipCentering then\n hook.setPositionSmooth(HOOK_CAMERA_HOME, false, false)\n delay = delay + 0.5\n end\n local lookPos\n local objReferenceData = TOUR_SCRIPT[cardIndex].objReferenceData\n if objReferenceData ~= nil then\n local lookAtObj = guidReferenceApi.getObjectByOwnerAndType(objReferenceData.owner, objReferenceData.type)\n lookPos = lookAtObj.getPosition()\n lookPos.y = TOUR_SCRIPT[cardIndex].distanceFromObj or 0\n -- Since camera isn't directly above the hook, changing the Y affects the visual position of\n -- whatever object we're trying to look at. This is an approximation, but close enough to\n -- keep the object more centered\n lookPos.x = lookPos.x - lookPos.y / 2\n elseif TOUR_SCRIPT[cardIndex].showPos ~= nil then\n lookPos = TOUR_SCRIPT[cardIndex].showPos\n end\n if lookPos ~= nil then\n Wait.time(function()\n hook.setPositionSmooth(lookPos, false, false)\n end, delay)\n delay = delay + 0.5\n end\n Wait.time(function() Global.UI.show(internal.getUiId(CARD_ID, playerColor)) end, delay)\n end\n\n -- Hides the current card being shown to a player. This can be in preparation for showing the\n -- next card, or ending the tour.\n ---@param playerColor string Player color to hide the current card for\n internal.hideCard = function(playerColor)\n Global.UI.hide(internal.getUiId(CARD_ID, playerColor))\n end\n\n -- Cleans up all the various resources associated with the tour, and (hopefully) resets the\n -- camera to the default position. Camera handling is erratic, the final card in the script\n -- should include instructions for the player to fix it.\n ---@param playerColor string Player color to clean up\n internal.finalizeTour = function(playerColor)\n local cameraHook = getObjectFromGUID(tourState[playerColor].cameraHookGuid)\n cameraHook.destruct()\n Player[playerColor].setCameraMode(\"ThirdPerson\")\n tourState[playerColor] = nil\n Wait.frames(function()\n Player[playerColor].lookAt(DEFAULT_CAMERA_POS)\n end, 3)\n end\n\n -- Updates the card UI to show the appropriate card configuration.\n ---@param playerColor string Player color to update card for\n internal.updateCardDisplay = function(playerColor)\n local index = tourState[playerColor].currentCardIndex\n Global.UI.setAttribute(internal.getUiId(LEFT_NARRATOR_ID, playerColor), \"image\", \"Inv-\" .. TOUR_SCRIPT[index].narrator)\n Global.UI.setAttribute(internal.getUiId(RIGHT_NARRATOR_ID, playerColor), \"image\", \"Inv-\" .. TOUR_SCRIPT[index].narrator)\n Global.UI.setAttribute(internal.getUiId(TEXT_ID, playerColor), \"text\", \"\\\"\" .. TOUR_SCRIPT[index].text .. \"\\\"\")\n local cardPos = TOUR_SCRIPT[index].position or \"north\"\n Global.UI.setAttribute(internal.getUiId(CARD_ID, playerColor), \"position\", SCREEN_POSITIONS[cardPos])\n Global.UI.setAttribute(internal.getUiId(NEXT_BUTTON_ID, playerColor), \"active\", index \u003c #TOUR_SCRIPT)\n\n -- Adjust images so the narrator is on the left or right, as defined by the card\n if TOUR_SCRIPT[index].speakerSide == \"right\" then\n Global.UI.setAttribute(internal.getUiId(LEFT_NARRATOR_ID, playerColor), \"active\", false)\n Global.UI.setAttribute(internal.getUiId(RIGHT_NARRATOR_ID, playerColor), \"active\", true)\n Global.UI.setAttribute(internal.getUiId(BUBBLE_ID, playerColor), \"rotation\", \"0 180 0\")\n Global.UI.setAttribute(internal.getUiId(TEXT_ID, playerColor), \"offsetXY\", \"-15 -15\")\n Global.UI.setAttribute(internal.getUiId(NEXT_BUTTON_ID, playerColor), \"offsetXY\", \"-35 -45\")\n Global.UI.setAttribute(internal.getUiId(STOP_BUTTON_ID, playerColor), \"offsetXY\", \"5 -45\")\n else\n Global.UI.setAttribute(internal.getUiId(LEFT_NARRATOR_ID, playerColor), \"active\", true)\n Global.UI.setAttribute(internal.getUiId(RIGHT_NARRATOR_ID, playerColor), \"active\", false)\n Global.UI.setAttribute(internal.getUiId(BUBBLE_ID, playerColor), \"rotation\", \"0 0 0\")\n Global.UI.setAttribute(internal.getUiId(TEXT_ID, playerColor), \"offsetXY\", \"15 -15\")\n Global.UI.setAttribute(internal.getUiId(NEXT_BUTTON_ID, playerColor), \"offsetXY\", \"-5 -45\")\n Global.UI.setAttribute(internal.getUiId(STOP_BUTTON_ID, playerColor), \"offsetXY\", \"35 -45\")\n end\n end\n\n -- Creates a small, transparent object which the camera will be attached to in order to move the\n -- user's view around the table. This should be called only at the beginning of the tour. Once\n -- creation is complete the user's camera will be attached to the hook and the first card will be\n -- shown.\n ---@param playerColor string Player color to create the hook for\n internal.createCameraHook = function(playerColor)\n local hookData = {\n Name = \"BlockSquare\",\n Transform = {\n posX = HOOK_CAMERA_HOME.x,\n posY = HOOK_CAMERA_HOME.y,\n posZ = HOOK_CAMERA_HOME.z,\n rotX = 0,\n rotY = 270,\n rotZ = 0,\n scaleX = 0.1,\n scaleY = 0.1,\n scaleZ = 0.1,\n },\n ColorDiffuse = {\n r = 0,\n g = 0,\n b = 0,\n a = 0,\n },\n Locked = true,\n GMNotes = playerColor\n }\n\n spawnObjectData({ data = hookData, callback_function = internal.onHookCreated })\n end\n\n -- Callback for creation of the camera hook object. Will attach the camera and show the current\n -- (presumably first) card.\n ---@param hook tts__Object Created object\n internal.onHookCreated = function(hook)\n local playerColor = hook.getGMNotes()\n tourState[playerColor].cameraHookGuid = hook.getGUID()\n Player[playerColor].attachCameraToObject({\n object = hook,\n offset = { x = -20, y = 30, z = 0 }\n })\n internal.showCurrentCard(playerColor)\n end\n\n -- Creates an XMLUI entry in Global for a player-specific tour card. Dynamically creating this\n -- is somewhat complex, but ensures we can properly handle any player color.\n ---@param playerColor string Player color to create the card for\n internal.createTourCard = function(playerColor)\n -- Make sure the card doesn't exist before we create a new one\n if Global.UI.getAttributes(internal.getUiId(CARD_ID, playerColor)) ~= nil then return end\n \n tourCardTemplate.attributes.id = internal.getUiId(CARD_ID, playerColor)\n tourCardTemplate.children[1].attributes.id = internal.getUiId(LEFT_NARRATOR_ID, playerColor)\n tourCardTemplate.children[2].attributes.id = internal.getUiId(RIGHT_NARRATOR_ID, playerColor)\n tourCardTemplate.children[3].attributes.id = internal.getUiId(BUBBLE_ID, playerColor)\n tourCardTemplate.children[4].attributes.id = internal.getUiId(TEXT_ID, playerColor)\n tourCardTemplate.children[5].attributes.id = internal.getUiId(NEXT_BUTTON_ID, playerColor)\n tourCardTemplate.children[5].attributes.onClick = self.getGUID() .. \"/nextCard\"\n tourCardTemplate.children[6].attributes.id = internal.getUiId(STOP_BUTTON_ID, playerColor)\n tourCardTemplate.children[6].attributes.onClick = self.getGUID() .. \"/stopTour\"\n internal.setDeepVisibility(tourCardTemplate, playerColor)\n\n local globalXml = Global.UI.getXmlTable()\n table.insert(globalXml, tourCardTemplate)\n Global.UI.setXmlTable(globalXml)\n end\n\n -- Panels don't cause their children to inherit their visibility value, so this recurses down the\n -- XML table to set all children to the same visibility.\n ---@param xmlUi table Lua table describing the XML\n ---@param playerColor string String color of the player to make this visible for\n internal.setDeepVisibility = function(xmlUi, playerColor)\n xmlUi.attributes.visibility = \"\" .. playerColor\n if xmlUi.children ~= nil then\n for _, child in ipairs(xmlUi.children) do\n internal.setDeepVisibility(child, playerColor)\n end\n end\n end\n\n internal.getUiId = function(baseId, playerColor)\n return baseId .. \"_\" .. playerColor\n end\n\n return TourManager\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/tour/TourCard\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Table definition for the tour card layout. This is functionally XMLUI in Lua form, but using\n-- this for dynamic creation ensures we can handle any player color without needing 10\n-- near-duplicate definitions in Global.xml\n\ntourCardTemplate = {\n tag = \"Panel\",\n attributes = {\n id = \"tourCard\",\n height = 215,\n width = 330,\n rotation = \"0 0 0\",\n position = \"0 300 30\",\n showAnimation = \"FadeIn\",\n hideAnimation = \"FadeOut\",\n active = false\n },\n children = {\n {\n tag = \"Image\",\n attributes = {\n id = \"tourNarratorImageLeft\",\n height = 120,\n width = 80,\n rectAlignment = \"UpperLeft\",\n offsetXY = \"-80 0\"\n -- Image will be set when the card is updated\n }\n },\n {\n tag = \"Image\",\n attributes = {\n id = \"tourNarratorImageRight\",\n active = false,\n height = 125,\n width = 80,\n rectAlignment = \"UpperRight\",\n offsetXY = \"80 0\"\n -- Image will be set when the card is updated\n }\n },\n {\n tag = \"Image\",\n attributes = {\n id = \"tourSpeechBubble\",\n color = \"#F5F5DC\",\n height = 215,\n width = 330,\n rectAlignment = \"MiddleCenter\",\n image = \"SpeechBubble\"\n }\n },\n {\n tag = \"Text\",\n attributes = {\n id = \"tourText\",\n -- Everything on this is double-sized and scaled down to keep the text sharps\n height = 370,\n width = 520,\n scale = \"0.5 0.5 1\",\n rectAlignment = \"UpperCenter\",\n offsetXY = \"15 -15\",\n resizeTextForBestFit = true,\n resizeTextMinSize = 20,\n resizeTextMaxSize = 32,\n color = \"#050505\",\n alignment = \"UpperLeft\",\n horizontalOverflow = \"wrap\"\n }\n },\n {\n tag = \"Image\",\n attributes = {\n id = \"tourNext\",\n height = 45,\n width = 45,\n rectAlignment = \"LowerRight\",\n offsetXY = \"-5 -45\",\n image = \"NextArrow\"\n }\n },\n {\n tag = \"Image\",\n attributes = {\n id = \"tourStop\",\n height = 45,\n width = 45,\n rectAlignment = \"LowerLeft\",\n offsetXY = \"35 -45\",\n image = \"Exit\"\n }\n }\n }\n}\nend)\n__bundle_register(\"core/tour/TourScript\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Script for the SCED tour. Documentation and definitions to come.\n\nTOUR_SCRIPT = {\n {\n narrator = \"Roland\",\n text = \"Despite my best efforts, looks like you found us. You may live to regret that. As long as you're here though we might as well show you around.\\n\\nUse the arrow to move forward, and if the horrors get to be too much you can quit whenever you like. Ready to get started?\",\n position = \"center\"\n },\n {\n narrator = \"Darrell\",\n text = \"Cameras can be tricky things. Best you leave handling it to the professionals during the tour. Don't try to move the camera until the tour is complete.\\n\\nOnce we're done, remember you can use the 'p' key to switch back to third-person mode, and the spacebar to reset the position.\",\n position = \"center\",\n speakerSide = \"right\"\n },\n {\n narrator = \"Daisy\",\n text = \"If you're new to the game, the library here has everything you'll need. A little research can go a long way, and looking into old newspapers for the weird and unusual can yield some surprisingly helpful information.\\n\\nI put a few right there that might prove enlightening.\",\n objReferenceData = { owner = \"Mythos\", type = \"RulesReference\" },\n distanceFromObj = 20,\n position = \"west\",\n speakerSide = \"right\"\n },\n {\n narrator = \"Mandy\",\n text = \"To survive what's coming you'll need a deck. If it's safely hidden away on ArkhamDB you can load it here, and even find the newest version after an upgrade without changing the ID.\\n\\nNo need to publish all your decks, use 'Private' and you can see it. Just make sure to select 'Make your decks public' in ArkhamDB.\",\n objReferenceData = { owner = \"Mythos\", type = \"DeckImporter\" },\n distanceFromObj = -5,\n position = \"northwest\",\n skipCentering = true\n },\n {\n narrator = \"Daniela\",\n text = \"I prefer the hands-on approach to building things, if you do too you can build a deck yourself.\\n\\nAll the cards you could ever need are here, laid out like a disassembled engine. Place the cards on the table, copy them for your deck, and you'll be ready for anything.\",\n objReferenceData = { owner = \"Mythos\", type = \"PlayerCardPanel\" },\n distanceFromObj = -7,\n position = \"south\",\n speakerSide = \"right\"\n },\n {\n narrator = \"Finn\",\n text = \"Ready to face the unknown? We've smuggled shocking revelations and devious enemies from all over the world. Download the campaign you want to play, then Place it on the table to see the scenarios.\\n\\nJust remember - if it turns out to be too much for you, I was never here.\",\n objReferenceData = { owner = \"Mythos\", type = \"CampaignThePathToCarcosa\" },\n distanceFromObj = 20,\n position = \"northwest\",\n skipCentering = true\n },\n {\n narrator = \"Diana\",\n text = \"These symbols on the bottom right are a repository of arcane knowledge, containing all the official content to download plus some deviously creative works from fans. One should beware those who seem too fond of the darkness, but you cannot deny the quality of their efforts.\\n\\nDon't see anything here? Only promoted players can access these.\",\n position = \"southeast\"\n },\n {\n narrator = \"Winifred\",\n text = \"No good aviator would fly a plane she didn't know and hadn't tweaked a bit herself. The gear icon contains settings to customize your play experience, from alternate ways to track your clues to a variety of helpers to streamline the game.\\n\\nEverything here is optional, but who doesn't want to go as fast as they can? Just remember that all settings affect all players, so strap in and trust your pilot!\",\n position = \"southeast\"\n },\n {\n narrator = \"Amina\",\n text = \"This is the Mythos area. Encounter cards, acts, and agenda will all be placed here while the large map below is where you will be exploring - be sure to set the number of investigators!\\n\\nYou can count doom on the agenda by clicking the large counter, and the smaller will automatically count doom tokens on the table. The chaos bag is in that book over on the right, and you can add or remove tokens from it whenever you need.\",\n showPos = { x = -2.85, y = 0, z = 0.55 },\n position = \"north\",\n speakerSide = \"right\"\n },\n {\n narrator = \"Gloria\",\n text = \"The evils that lurk in this world are out there, creeping ever closer. When they find you, this will easily draw a card from the encounter deck. The deck will even reshuffle itself when needed, for the enemies we face are unending.\",\n showPos = { x = -35, y = -20, z = 28 },\n position = \"west\",\n skipCentering = true\n },\n {\n narrator = \"Jacqueline\",\n text = \"When the ire of fate finds you and the chaos looms, this large button will draw a chaos token. Click it again to return the token to the bag.\\n\\nWhether a vision of the future or a curse from the opponents we face, if you need additional tokens a right-click will draw more. I wish you luck, but have a vision of red tentacles reaching for you...\",\n showPos = { x = -35, y = -20, z = 4.25 },\n position = \"north\",\n skipCentering = true,\n speakerSide = \"right\"\n },\n {\n narrator = \"Kohaku\",\n text = \"Folklorists, immersed in the rich narratives of blessings and curses, explore the essence of human beliefs. You can use this tool to control the amount of bless and curse tokens in the chaos bag. It will also display the amount in the bag (+ sealed on cards) for you. Remember to remove bless / curse tokens with this after resolving them.\",\n objReferenceData = { owner = \"Mythos\", type = \"BlessCurseManager\" },\n position = \"center\",\n skipCentering = true,\n speakerSide = \"left\"\n },\n {\n narrator = \"Preston\",\n text = \"I can afford to buy what I need, but for those less well-off we've provided an endless pool of tokens to track your game. Simply drag one out of the pools here.\\n\\nResources are my favorite of course, but damage and horror are as inevitable as taxes. I leave those to my bookkeeper though. Those tokens can work like counters, use the number keys to change the value.\",\n objReferenceData = { owner = \"Mythos\", type = \"ResourceTokenBag\" },\n position = \"north\",\n skipCentering = true,\n speakerSide = \"right\"\n },\n {\n narrator = \"Norman\",\n text = \"That's the end of the tour, but there's much more to discover if you look in the right places. Some cards have helpers on the right-click menu, and every new version adds new content and functions.\\n\\nDon't be afraid to explore, and best of luck out there! We'll all need it...\",\n position = \"center\",\n speakerSide = \"right\"\n }\n}\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/tour/TourStarter\")\nend)\n__bundle_register(\"core/tour/TourStarter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal tourManager = require(\"core/tour/TourManager\")\n\nfunction onLoad()\n self.createButton({\n click_function = \"startTour\",\n function_owner = self,\n position = { 1.27, 0.05, 0.035},\n width = 500,\n height = 20,\n color = { 0, 0, 0, 0 },\n -- TTS has a minium height for buttons, have to scale the Z-axis down to get the right size\n scale = { 1, 1, 0.82 },\n tooltip = \"Start the Tour\",\n })\n self.createButton({\n click_function = \"deleteStarter\",\n function_owner = self,\n position = { 1.27, 0.05, 0.309},\n width = 500,\n height = 20,\n color = { 0, 0, 0, 0 },\n -- TTS has a minium height for buttons, have to scale the Z-axis down to get the right size\n scale = { 1, 1, 0.82 },\n tooltip = \"Delete this Panel\",\n })\nend\n\nfunction startTour(_, playerColor, _)\n tourManager.startTour(playerColor)\nend\n\nfunction deleteStarter(_, _, _)\n self.destruct()\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Token", @@ -199689,7 +202849,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/PlayerCardPanel\")\nend)\n__bundle_register(\"arkhamdb/ArkhamDb\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local allCardsBagApi = require(\"playercards/AllCardsBagApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n\n local ArkhamDb = {}\n local internal = {}\n \n local tabooList = {}\n local configuration\n\n local RANDOM_WEAKNESS_ID = \"01000\"\n\n ---@class Request\n local Request = {}\n\n -- Sets up the ArkhamDb interface. Should be called from the parent object on load.\n ArkhamDb.initialize = function()\n configuration = internal.getConfiguration()\n Request.start({ configuration.api_uri, configuration.taboo }, function(status)\n local json = JSON.decode(internal.fixUtf16String(status.text))\n for _, taboo in pairs(json) do\n local cards = {}\n\n for _, card in pairs(JSON.decode(taboo.cards)) do\n cards[card.code] = true\n end\n\n tabooList[taboo.id] = {\n date = taboo.date_start,\n cards = cards\n }\n end\n return true, nil\n end)\n end\n\n -- Start the deck build process for the given player color and deck ID. This\n -- will retrieve the deck from ArkhamDB, and pass to a callback for processing.\n ---@param playerColor string Color name of the player mat to place this deck on (e.g. \"Red\").\n ---@param deckId string ArkhamDB deck id to be loaded\n ---@param isPrivate boolean Whether this deck is published or private on ArkhamDB\n ---@param loadNewest boolean Whether the newest version of this deck should be loaded\n ---@param loadInvestigators boolean Whether investigator cards should be loaded as part of this deck\n ---@param callback function Callback which will be sent the results of this load\n --- Parameters to the callback will be:\n --- slots table A map of card ID to count in the deck\n --- investigatorCode String. ID of the investigator in this deck\n --- customizations table The decoded table of customization upgrades in this deck\n --- playerColor String. Color this deck is being loaded for\n ---@return boolean\n ---@return string\n ArkhamDb.getDecklist = function(\n playerColor,\n deckId,\n isPrivate,\n loadNewest,\n loadInvestigators,\n callback)\n -- Get a simple card to see if the bag indexes are complete. If not, abort\n -- the deck load. The called method will handle player notification.\n local checkCard = allCardsBagApi.getCardById(\"01001\")\n if (checkCard ~= nil and checkCard.data == nil) then\n return false, \"Indexing not complete\"\n end\n\n local deckUri = {\n configuration.api_uri,\n isPrivate and configuration.private_deck or configuration.public_deck,\n deckId\n }\n\n local deck = Request.start(deckUri, function(status)\n if string.find(status.text, \"\u003c!DOCTYPE html\u003e\") then\n internal.maybePrint(\"Private deck ID \" .. deckId .. \" is not shared\", playerColor)\n return false, \"Private deck \" .. deckId .. \" is not shared\"\n end\n local json = JSON.decode(status.text)\n\n if not json then\n internal.maybePrint(\"Deck ID \" .. deckId .. \" not found\", playerColor)\n return false, \"Deck not found!\"\n end\n\n return true, json\n end)\n\n deck:with(internal.onDeckResult, playerColor, loadNewest, loadInvestigators, callback)\n end\n\n -- Logs that a card could not be loaded in the mod by printing it to the console in the given\n -- color of the player owning the deck. Attempts to look up the name on ArkhamDB for clarity,\n -- but prints the card ID if the name cannot be retrieved.\n ---@param cardId string ArkhamDB ID of the card that could not be found\n ---@param playerColor string Color of the player's deck that had the problem\n ArkhamDb.logCardNotFound = function(cardId, playerColor)\n local request = Request.start({\n configuration.api_uri,\n configuration.cards,\n cardId\n },\n function(result)\n local adbCardInfo = JSON.decode(internal.fixUtf16String(result.text))\n local cardName = adbCardInfo.real_name\n if (cardName ~= nil) then\n if (adbCardInfo.xp ~= nil and adbCardInfo.xp \u003e 0) then\n cardName = cardName .. \" (\" .. adbCardInfo.xp .. \")\"\n end\n internal.maybePrint(\"Card not found: \" .. cardName .. \", card ID \" .. cardId, playerColor)\n else\n internal.maybePrint(\"Card not found in ArkhamDB/Index, ID \" .. cardId, playerColor)\n end\n end)\n end\n\n -- Callback when the deck information is received from ArkhamDB. Parses the\n -- response then applies standard transformations to the deck such as adding\n -- random weaknesses and checking for taboos. Once the deck is processed,\n -- passes to loadCards to actually spawn the defined deck.\n ---@param deck table ArkhamImportDeck\n ---@param playerColor string Color name of the player mat to place this deck on (e.g. \"Red\")\n ---@param loadNewest boolean Whether the newest version of this deck should be loaded\n ---@param loadInvestigators boolean Whether investigator cards should be loaded as part of this deck\n ---@param callback function Callback which will be sent the results of this load.\n --- Parameters to the callback will be:\n --- slots table A map of card ID to count in the deck\n --- investigatorCode String. ID of the investigator in this deck\n --- bondedList A table of cardID keys to meaningless values. Card IDs in this list were\n --- added from a parent bonded card.\n --- customizations table The decoded table of customization upgrades in this deck\n --- playerColor String. Color this deck is being loaded for\n internal.onDeckResult = function(deck, playerColor, loadNewest, loadInvestigators, callback)\n -- Load the next deck in the upgrade path if the option is enabled\n if (loadNewest and deck.next_deck ~= nil and deck.next_deck ~= \"\") then\n buildDeck(playerColor, deck.next_deck)\n return\n end\n\n internal.maybePrint(table.concat({ \"Found decklist: \", deck.name }), playerColor)\n\n -- Initialize deck slot table and perform common transformations. The order of these should not\n -- be changed, as later steps may act on cards added in each. For example, a random weakness or\n -- investigator may have bonded cards or taboo entries, and should be present\n local slots = deck.slots\n internal.maybeDrawRandomWeakness(slots, playerColor)\n\n -- handles alternative investigators (parallel, promo or revised art)\n local loadAltInvestigator = \"normal\"\n if loadInvestigators then\n loadAltInvestigator = internal.addInvestigatorCards(deck, slots)\n end\n\n internal.maybeModifyDeckFromDescription(slots, deck.description_md, playerColor)\n internal.maybeAddSummonedServitor(slots)\n internal.maybeAddOnTheMend(slots, playerColor)\n internal.maybeAddRealityAcidReference(slots)\n local bondList = internal.extractBondedCards(slots)\n internal.checkTaboos(deck.taboo_id, slots, playerColor)\n internal.maybeAddUpgradeSheets(slots)\n\n -- get upgrades for customizable cards\n local customizations = {}\n if deck.meta then\n customizations = JSON.decode(deck.meta)\n end\n\n callback(slots, deck.investigator_code, bondList, customizations, playerColor, loadAltInvestigator)\n end\n\n -- Checks to see if the slot list includes the random weakness ID. If it does,\n -- removes it from the deck and replaces it with the ID of a random basic weakness provided by the\n -- all cards bag\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n --- of those cards which will be spawned\n ---@param playerColor string Color of the player this deck is being loaded for. Used for broadcast\n --- if a weakness is added.\n internal.maybeDrawRandomWeakness = function(slots, playerColor)\n local randomWeaknessAmount = slots[RANDOM_WEAKNESS_ID] or 0\n slots[RANDOM_WEAKNESS_ID] = nil\n\n if randomWeaknessAmount ~= 0 then\n for i=1, randomWeaknessAmount do\n local weaknessId = allCardsBagApi.getRandomWeaknessId()\n slots[weaknessId] = (slots[weaknessId] or 0) + 1\n end\n internal.maybePrint(\"Added \" .. randomWeaknessAmount .. \" random basic weakness(es) to deck\", playerColor)\n end\n end\n\n -- Adds both the investigator (XXXXX) and minicard (XXXXX-m) slots with one copy each\n ---@param deck table The processed ArkhamDB deck response\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the\n --- number of those cards which will be spawned\n ---@return string: Contains the name of the art that should be loaded (\"normal\", \"promo\" or \"revised\")\n internal.addInvestigatorCards = function(deck, slots)\n local investigatorId = deck.investigator_code\n slots[investigatorId .. \"-m\"] = 1\n local deckMeta = JSON.decode(deck.meta)\n\n -- handling alternative investigator art and parallel investigators\n local loadAltInvestigator = \"normal\"\n if deckMeta ~= nil then\n local altFrontId = tonumber(deckMeta.alternate_front) or 0\n local altBackId = tonumber(deckMeta.alternate_back) or 0\n local altArt = { front = \"normal\", back = \"normal\" }\n\n -- translating front ID\n if altFrontId \u003e 90000 and altFrontId \u003c 90100 then\n altArt.front = \"parallel\"\n elseif altFrontId \u003e 01500 and altFrontId \u003c 01506 then\n altArt.front = \"revised\"\n elseif altFrontId \u003e 98000 then\n altArt.front = \"promo\"\n end\n\n -- translating back ID\n if altBackId \u003e 90000 and altBackId \u003c 90100 then\n altArt.back = \"parallel\"\n elseif altBackId \u003e 01500 and altBackId \u003c 01506 then\n altArt.back = \"revised\"\n elseif altBackId \u003e 98000 then\n altArt.back = \"promo\"\n end\n\n -- updating investigatorID based on alt investigator selection\n -- precedence: parallel \u003e promo \u003e revised\n if altArt.front == \"parallel\" then\n if altArt.back == \"parallel\" then\n investigatorId = investigatorId .. \"-p\"\n else\n investigatorId = investigatorId .. \"-pf\"\n end\n elseif altArt.back == \"parallel\" then\n investigatorId = investigatorId .. \"-pb\"\n elseif altArt.front == \"promo\" or altArt.back == \"promo\" then\n loadAltInvestigator = \"promo\"\n elseif altArt.front == \"revised\" or altArt.back == \"revised\" then\n loadAltInvestigator = \"revised\"\n end\n end\n slots[investigatorId] = 1\n deck.investigator_code = investigatorId\n return loadAltInvestigator\n end\n\n -- Process the card list looking for the customizable cards, and add their upgrade sheets if needed\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n internal.maybeAddUpgradeSheets = function(slots)\n for cardId, _ in pairs(slots) do\n -- upgrade sheets for customizable cards\n local upgradesheet = allCardsBagApi.getCardById(cardId .. \"-c\")\n if upgradesheet ~= nil then\n slots[cardId .. \"-c\"] = 1\n end\n end\n end\n\n -- Process the card list looking for the Summoned Servitor, and add its minicard to the list if\n -- needed\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n internal.maybeAddSummonedServitor = function(slots)\n if slots[\"09080\"] ~= nil then\n slots[\"09080-m\"] = 1\n end\n end\n\n -- On the Mend should have 1-per-investigator copies set aside, but ArkhamDB always sends 1. Update\n -- the count based on the investigator count\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n ---@param playerColor string Color of the player this deck is being loaded for. Used for broadcast if an error occurs\n internal.maybeAddOnTheMend = function(slots, playerColor)\n if slots[\"09006\"] ~= nil then\n local investigatorCount = playAreaApi.getInvestigatorCount()\n if investigatorCount ~= nil then\n slots[\"09006\"] = investigatorCount\n else\n internal.maybePrint(\"Something went wrong with the load, adding 4 copies of On the Mend\", playerColor)\n slots[\"09006\"] = 4\n end\n end\n end\n\n -- Process the card list looking for Reality Acid and adds the reference sheet when needed\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n internal.maybeAddRealityAcidReference = function(slots)\n if slots[\"89004\"] ~= nil then\n slots[\"89005\"] = 1\n end\n end\n\n -- Processes the deck description from ArkhamDB and modifies the slot list accordingly\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n ---@param description string The deck desription from ArkhamDB\n internal.maybeModifyDeckFromDescription = function(slots, description, playerColor)\n -- check for import instructions\n local pos = string.find(description, \"++SCED import instructions++\")\n if not pos then return end\n\n -- remove everything before instructions\n local tempStr = string.sub(description, pos)\n\n -- parse each line in instructions\n for line in tempStr:gmatch(\"([^\\n]+)\") do\n -- remove dashes at the start\n line = line:gsub(\"%- \", \"\")\n\n -- remove spaces\n line = line:gsub(\"%s\", \"\")\n\n -- remove balanced brackets\n line = line:gsub(\"%b()\", \"\")\n line = line:gsub(\"%b[]\", \"\")\n\n -- get instructor\n local instructor = \"\"\n for word in line:gmatch(\"%a+:\") do\n instructor = word\n break\n end\n\n -- go to the next line if no valid instructor found\n if instructor ~= \"add:\" and instructor ~= \"remove:\" then\n goto nextLine\n end\n\n -- remove instructor from line\n line = line:gsub(instructor, \"\")\n\n -- evaluate instructions\n for str in line:gmatch(\"([^,]+)\") do\n if instructor == \"add:\" then\n slots[str] = (slots[str] or 0) + 1\n elseif instructor == \"remove:\" then\n if slots[str] == nil then\n internal.maybePrint(\"Tried to remove card ID \" .. str .. \", but didn't find card in deck.\", playerColor)\n else\n slots[str] = math.max(slots[str] - 1, 0)\n\n -- fully remove cards that have a quantity of 0\n if slots[str] == 0 then\n slots[str] = nil\n\n -- also remove related minicard\n slots[str .. \"-m\"] = nil\n end\n end\n end\n end\n\n -- jump mark at the end of the loop\n ::nextLine::\n end\n end\n\n -- Process the slot list and looks for any cards which are bonded to those in the deck. Adds those cards to the slot list.\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned\n internal.extractBondedCards = function(slots)\n -- Create a list of bonded cards first so we don't modify slots while iterating\n local bondedCards = { }\n local bondedList = { }\n for cardId, cardCount in pairs(slots) do\n local card = allCardsBagApi.getCardById(cardId)\n if (card ~= nil and card.metadata.bonded ~= nil) then\n for _, bond in ipairs(card.metadata.bonded) do\n -- add a bonded card for each copy of the parent card (except for Pendant of the Queen)\n if bond.id == \"06022\" then\n bondedCards[bond.id] = bond.count\n else\n bondedCards[bond.id] = bond.count * cardCount\n end\n -- We need to know which cards are bonded to determine their position, remember them\n bondedList[bond.id] = true\n -- Also adding taboo versions of bonded cards to the list\n bondedList[bond.id .. \"-t\"] = true\n end\n end\n end\n -- Add any bonded cards to the main slots list\n for bondedId, bondedCount in pairs(bondedCards) do\n slots[bondedId] = bondedCount\n end\n\n return bondedList\n end\n\n -- Check the deck for cards on its taboo list. If they're found, replace the entry in the slot with the Taboo id (i.e. \"XXXX\" becomes \"XXXX-t\")\n ---@param tabooId string The deck's taboo ID, taken from the deck response taboo_id field. May be nil, indicating that no taboo list should be used\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned\n internal.checkTaboos = function(tabooId, slots, playerColor)\n if tabooId then\n for cardId, _ in pairs(tabooList[tabooId].cards) do\n if slots[cardId] ~= nil then\n -- Make sure there's a taboo version of the card before we replace it\n -- SCED only maintains the most recent taboo cards. If a deck is using\n -- an older taboo list it's possible the card isn't a taboo any more\n local tabooCard = allCardsBagApi.getCardById(cardId .. \"-t\")\n if tabooCard == nil then\n local basicCard = allCardsBagApi.getCardById(cardId)\n internal.maybePrint(\"Taboo version for \" .. basicCard.data.Nickname .. \" is not available. Using standard version\", playerColor)\n else\n slots[cardId .. \"-t\"] = slots[cardId]\n slots[cardId] = nil\n end\n end\n end\n end\n end\n\n internal.maybePrint = function(message, playerColor)\n if playerColor ~= \"None\" then\n printToAll(message, playerColor)\n end\n end\n\n -- Gets the ArkhamDB config info from the configuration object.\n ---@return table: configuration data\n internal.getConfiguration = function()\n local configuration = getObjectsWithTag(\"import_configuration_provider\")[1].getTable(\"configuration\")\n printPriority = configuration.priority\n return configuration\n end\n\n internal.fixUtf16String = function(str)\n return str:gsub(\"\\\\u(%w%w%w%w)\", function(match)\n return string.char(tonumber(match, 16))\n end)\n end\n\n Request = {\n is_done = false,\n is_successful = false\n }\n\n -- Creates a new instance of a Request. Should not be directly called. Instead use Request.start() and Request.deferred().\n ---@param uri table\n ---@param configure fun(request, status)\n ---@return Request\n function Request:new(uri, configure)\n local this = {}\n\n setmetatable(this, self)\n self.__index = self\n\n if type(uri) == \"table\" then\n uri = table.concat(uri, \"/\")\n end\n\n this.uri = uri\n WebRequest.get(uri, function(status) configure(this, status) end)\n\n return this\n end\n\n -- Creates a new request. on_success should set the request's is_done, is_successful, and content variables.\n -- Deferred should be used when you don't want to set is_done immediately (such as if you want to wait for another request to finish)\n ---@param uri table\n ---@param on_success fun(request, status, vararg)\n ---@param on_error fun(status)|nil\n ---@return Request\n function Request.deferred(uri, on_success, on_error, ...)\n local parameters = table.pack(...)\n return Request:new(uri, function(request, status)\n if (status.is_done) then\n if (status.is_error) then\n request.error_message = on_error and on_error(status, table.unpack(parameters)) or status.error\n request.is_successful = false\n request.is_done = true\n else\n on_success(request, status)\n end\n end\n end)\n end\n\n -- Creates a new request. on_success should return whether the resultant data is as expected, and the processed content of the request.\n ---@param uri table\n ---@param on_success fun(status, vararg): boolean, any\n ---@param on_error nil|fun(status, vararg): string\n ---@vararg any\n ---@return Request\n function Request.start(uri, on_success, on_error, ...)\n local parameters = table.pack(...)\n return Request.deferred(uri, function(request, status)\n local result, message = on_success(status, table.unpack(parameters))\n if not result then request.error_message = message else request.content = message end\n request.is_successful = result\n request.is_done = true\n end, on_error, table.unpack(parameters))\n end\n\n ---@param requests Request[]\n ---@param on_success fun(content: any, vararg: any)\n ---@param on_error fun(requests: Request, vararg: any)|nil\n ---@vararg any\n function Request.with_all(requests, on_success, on_error, ...)\n local parameters = table.pack(...)\n\n Wait.condition(function()\n local results = {}\n local errors = {}\n\n for _, request in ipairs(requests) do\n if request.is_successful then\n table.insert(results, request.content)\n else\n table.insert(errors, request)\n end\n end\n\n if (#errors \u003c= 0) then\n on_success(results, table.unpack(parameters))\n elseif on_error == nil then\n for _, request in ipairs(errors) do\n internal.maybePrint(table.concat({ \"[ERROR]\", request.uri, \":\", request.error_message }))\n end\n else\n on_error(requests, table.unpack(parameters))\n end\n end, function()\n for _, request in ipairs(requests) do\n if not request.is_done then return false end\n end\n return true\n end)\n end\n\n function Request:with(callback, ...)\n local arguments = table.pack(...)\n Wait.condition(function()\n if self.is_successful then\n callback(self.content, table.unpack(arguments))\n end\n end, function() return self.is_done\n end)\n end\n\n return ArkhamDb\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"playercards/AllCardsBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local AllCardsBagApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getAllCardsBag()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"AllCardsBag\")\n end\n\n -- Returns a specific card from the bag, based on ArkhamDB ID\n ---@param id table String ID of the card to retrieve\n ---@return table table\n -- If the indexes are still being constructed, an empty table is\n -- returned. Otherwise, a single table with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardById = function(id)\n return getAllCardsBag().call(\"getCardById\", {id = id})\n end\n\n -- Gets a random basic weakness from the bag. Once a given ID has been returned\n -- it will be removed from the list and cannot be selected again until a reload\n -- occurs or the indexes are rebuilt, which will refresh the list to include all\n -- weaknesses.\n ---@return string: ID of the selected weakness.\n AllCardsBagApi.getRandomWeaknessId = function()\n return getAllCardsBag().call(\"getRandomWeaknessId\")\n end\n\n AllCardsBagApi.isIndexReady = function()\n return getAllCardsBag().call(\"isIndexReady\")\n end\n\n -- Called by Hotfix bags when they load. If we are still loading indexes, then\n -- the all cards and hotfix bags are being loaded together, and we can ignore\n -- this call as the hotfix will be included in the initial indexing. If it is\n -- called once indexing is complete it means the hotfix bag has been added\n -- later, and we should rebuild the index to integrate the hotfix bag.\n AllCardsBagApi.rebuildIndexForHotfix = function()\n return getAllCardsBag().call(\"rebuildIndexForHotfix\")\n end\n\n -- Searches the bag for cards which match the given name and returns a list. Note that this is\n -- an O(n) search without index support. It may be slow.\n ---@param name string or string fragment to search for names\n ---@param exact boolean Whether the name match should be exact\n AllCardsBagApi.getCardsByName = function(name, exact)\n return getAllCardsBag().call(\"getCardsByName\", {name = name, exact = exact})\n end\n\n AllCardsBagApi.isBagPresent = function()\n return getAllCardsBag() and true\n end\n\n -- Returns a list of cards from the bag matching a class and level (0 or upgraded)\n ---@param class string class to retrieve (\"Guardian\", \"Seeker\", etc)\n ---@param upgraded boolean true for upgraded cards (Level 1-5), false for Level 0\n ---@return table: If the indexes are still being constructed, returns an empty table.\n -- Otherwise, a list of tables, each with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded)\n return getAllCardsBag().call(\"getCardsByClassAndLevel\", {class = class, upgraded = upgraded})\n end\n\n AllCardsBagApi.getCardsByCycle = function(cycle)\n return getAllCardsBag().call(\"getCardsByCycle\", cycle)\n end\n\n AllCardsBagApi.getUniqueWeaknesses = function()\n return getAllCardsBag().call(\"getUniqueWeaknesses\")\n end\n\n return AllCardsBagApi\nend\nend)\n__bundle_register(\"playercards/PlayerCardPanel\", function(require, _LOADED, __bundle_register, __bundle_modules)\n---@diagnostic disable: param-type-mismatch\nrequire(\"playercards/PlayerCardPanelData\")\n\nlocal allCardsBagApi = require(\"playercards/AllCardsBagApi\")\nlocal arkhamDb = require(\"arkhamdb/ArkhamDb\")\nlocal spawnBag = require(\"playercards/SpawnBag\")\n\n-- Size and position information for the three rows of class buttons\nlocal CIRCLE_BUTTON_SIZE = 250\nlocal CLASS_BUTTONS_X_OFFSET = 0.1325\nlocal INVESTIGATOR_ROW_START = Vector(0.125, 0.1, -0.447)\nlocal LEVEL_ZERO_ROW_START = Vector(0.125, 0.1, -0.007)\nlocal UPGRADED_ROW_START = Vector(0.125, 0.1, 0.333)\n\n-- Size and position information for the two blocks of other buttons\nlocal MISC_BUTTONS_X_OFFSET = 0.155\nlocal WEAKNESS_ROW_START = Vector(0.157, 0.1, 0.666)\nlocal OTHER_ROW_START = Vector(0.605, 0.1, 0.666)\n\n-- Size and position information for the Cycle (box) buttons\nlocal CYCLE_BUTTON_SIZE = 468\nlocal CYCLE_BUTTON_START = Vector(-0.716, 0.1, -0.39)\nlocal CYCLE_COLUMN_COUNT = 3\nlocal CYCLE_BUTTONS_X_OFFSET = 0.267\nlocal CYCLE_BUTTONS_Z_OFFSET = 0.2665\n\nlocal STARTER_DECK_MODE_SELECTED_COLOR = { 0.2, 0.2, 0.2, 0.8 }\nlocal TRANSPARENT = { 0, 0, 0, 0 }\nlocal STARTER_DECK_MODE_STARTERS = \"starters\"\nlocal STARTER_DECK_MODE_CARDS_ONLY = \"cards\"\n\nlocal FACE_UP_ROTATION = { x = 0, y = 270, z = 0}\nlocal FACE_DOWN_ROTATION = { x = 0, y = 270, z = 180}\n\n-- ---------- IMPORTANT ----------\n-- Coordinates defined below are in global dimensions relative to the panel - DO NOT USE THESE\n-- DIRECTLY. Call scalePositions() before use, and reference the variables below\n\n-- Layout width for a single card, in global coordinate space\nlocal CARD_WIDTH = 2.3\n\n-- Coordinates to begin laying out cards. These vary based on the cards that are being placed by\n-- considering the width of the cards, number of cards, and desired spread intervals.\n-- IMPORTANT! Because of the mix of global card sizes and relative-to-scale positions, the X and Y\n-- coordinates on these provide global disances while the Z is local.\nlocal START_POSITIONS = {\n classCards = Vector(CARD_WIDTH * 9.5, 2, 1.4),\n investigator = Vector(6 * 2.5, 2, 1.3),\n cycle = Vector(CARD_WIDTH * 9.5, 2, 2.4),\n other = Vector(CARD_WIDTH * 9.5, 2, 1.4),\n randomWeakness = Vector(0, 2, 1.4),\n -- Because the card spread is handled by the SpawnBag, we don't know (programatically) where this\n -- should be placed. If more customizable cards are added it will need to be moved.\n summonedServitor = Vector(CARD_WIDTH * -7.5, 2, 1.7)\n}\n\n-- Shifts to move rows of cards, and groups of rows, as different groupings are laid out\nlocal CARD_ROW_OFFSET = 3.7\nlocal CARD_GROUP_OFFSET = 2\n\n-- Position offsets for investigator decks in investigator mode, defines the spacing for how the\n-- rows and columns are laid out\nlocal INVESTIGATOR_POSITION_SHIFT_ROW = Vector(0, 0, 11)\nlocal INVESTIGATOR_POSITION_SHIFT_COL = Vector(-6, 0, 0)\nlocal INVESTIGATOR_MAX_COLS = 6\n\n-- Positions relative to the minicard to place other stacks. Both signature card piles and starter\n-- decks use SIGNATURE_OFFSET\nlocal INVESTIGATOR_CARD_OFFSET = Vector(0, 0, 2.55)\nlocal INVESTIGATOR_SIGNATURE_OFFSET = Vector(0, 0, 5.75)\n\n-- USE THESE! Positions and offset shifts accounting for the scale of the panel\nlocal startPositions\nlocal cardRowOffset\nlocal cardGroupOffset\nlocal investigatorPositionShiftRow\nlocal investigatorPositionShiftCol\nlocal investigatorCardOffset\nlocal investigatorSignatureOffset\n\nlocal CLASS_LIST = { \"Guardian\", \"Seeker\", \"Rogue\", \"Mystic\", \"Survivor\", \"Neutral\" }\nlocal CYCLE_LIST = {\n \"Core\",\n \"The Dunwich Legacy\",\n \"The Path to Carcosa\",\n \"The Forgotten Age\",\n \"The Circle Undone\",\n \"The Dream-Eaters\",\n \"The Innsmouth Conspiracy\",\n \"Edge of the Earth\",\n \"The Scarlet Keys\",\n \"The Feast of Hemlock Vale\",\n \"Investigator Packs\"\n}\n\nlocal excludedNonBasicWeaknesses\n\nlocal starterDeckMode = STARTER_DECK_MODE_CARDS_ONLY\nlocal helpVisibleToPlayers = { }\n\nfunction onSave()\n return JSON.encode({ spawnBagState = spawnBag.getStateForSave() })\nend\n\nfunction onLoad(savedData)\n arkhamDb.initialize()\n if (savedData ~= nil) then\n local saveState = JSON.decode(savedData) or { }\n if (saveState.spawnBagState ~= nil) then\n spawnBag.loadFromSave(saveState.spawnBagState)\n end\n end\n buildExcludedWeaknessList()\n createButtons()\nend\n\n-- Build a list of non-basic weaknesses which should be excluded from the last weakness set,\n-- including all signature cards and evolved weaknesses.\nfunction buildExcludedWeaknessList()\n excludedNonBasicWeaknesses = { }\n for _, investigator in pairs(INVESTIGATORS) do\n for _, signatureId in ipairs(investigator.signatures) do\n excludedNonBasicWeaknesses[signatureId] = true\n end\n end\n for _, weaknessId in ipairs(EVOLVED_WEAKNESSES) do\n excludedNonBasicWeaknesses[weaknessId] = true\n end\nend\n\nfunction createButtons()\n createHelpButton()\n createInvestigatorButtons()\n createLevelZeroButtons()\n createUpgradedButtons()\n createWeaknessButtons()\n createOtherButtons()\n createCycleButtons()\n createClearButton()\n -- Create investigator mode buttons last so the indexes are set when we need to update them\n createInvestigatorModeButtons()\nend\n\nfunction createHelpButton()\n self.createButton({\n function_owner = self,\n click_function = \"toggleHelp\",\n position = Vector(0.845, 0.1, -0.855),\n height = 180,\n width = 180,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n })\nend\n\nfunction createInvestigatorButtons()\n local invButtonParams = {\n function_owner = self,\n height = CIRCLE_BUTTON_SIZE,\n width = CIRCLE_BUTTON_SIZE,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n }\n local buttonPos = INVESTIGATOR_ROW_START:copy()\n for _, class in ipairs(CLASS_LIST) do\n invButtonParams.click_function = \"spawnInvestigators\" .. class\n invButtonParams.position = buttonPos\n self.createButton(invButtonParams)\n buttonPos.x = buttonPos.x + CLASS_BUTTONS_X_OFFSET\n self.setVar(invButtonParams.click_function, function(_, _, _) spawnInvestigatorGroup(class) end)\n end\nend\n\nfunction createLevelZeroButtons()\n local l0ButtonParams = {\n function_owner = self,\n height = CIRCLE_BUTTON_SIZE,\n width = CIRCLE_BUTTON_SIZE,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n }\n local buttonPos = LEVEL_ZERO_ROW_START:copy()\n for _, class in ipairs(CLASS_LIST) do\n l0ButtonParams.click_function = \"spawnBasic\" .. class\n l0ButtonParams.position = buttonPos\n self.createButton(l0ButtonParams)\n buttonPos.x = buttonPos.x + CLASS_BUTTONS_X_OFFSET\n self.setVar(l0ButtonParams.click_function, function(_, _, _) spawnClassCards(class, false) end)\n end\nend\n\nfunction createUpgradedButtons()\n local upgradedButtonParams = {\n function_owner = self,\n height = CIRCLE_BUTTON_SIZE,\n width = CIRCLE_BUTTON_SIZE,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n }\n local buttonPos = UPGRADED_ROW_START:copy()\n for _, class in ipairs(CLASS_LIST) do\n upgradedButtonParams.click_function = \"spawnUpgraded\" .. class\n upgradedButtonParams.position = buttonPos\n self.createButton(upgradedButtonParams)\n buttonPos.x = buttonPos.x + CLASS_BUTTONS_X_OFFSET\n self.setVar(upgradedButtonParams.click_function, function(_, _, _) spawnClassCards(class, true) end)\n end\nend\n\nfunction createWeaknessButtons()\n local weaknessButtonParams = {\n function_owner = self,\n height = CIRCLE_BUTTON_SIZE,\n width = CIRCLE_BUTTON_SIZE,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n }\n local buttonPos = WEAKNESS_ROW_START:copy()\n weaknessButtonParams.click_function = \"spawnWeaknesses\"\n weaknessButtonParams.tooltip = \"All Weaknesses\"\n weaknessButtonParams.position = buttonPos\n self.createButton(weaknessButtonParams)\n buttonPos.x = buttonPos.x + MISC_BUTTONS_X_OFFSET\n weaknessButtonParams.click_function = \"spawnRandomWeakness\"\n weaknessButtonParams.tooltip = \"Random Basic Weakness\"\n weaknessButtonParams.position = buttonPos\n self.createButton(weaknessButtonParams)\nend\n\nfunction createOtherButtons()\n local otherButtonParams = {\n function_owner = self,\n height = CIRCLE_BUTTON_SIZE,\n width = CIRCLE_BUTTON_SIZE,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n }\n local buttonPos = OTHER_ROW_START:copy()\n otherButtonParams.click_function = \"spawnBonded\"\n otherButtonParams.tooltip = \"Bonded Cards\"\n otherButtonParams.position = buttonPos\n self.createButton(otherButtonParams)\n buttonPos.x = buttonPos.x + MISC_BUTTONS_X_OFFSET\n otherButtonParams.click_function = \"spawnUpgradeSheets\"\n otherButtonParams.tooltip = \"Customization Upgrade Sheets\"\n otherButtonParams.position = buttonPos\n self.createButton(otherButtonParams)\nend\n\nfunction createCycleButtons()\n local cycleButtonParams = {\n function_owner = self,\n height = CYCLE_BUTTON_SIZE,\n width = CYCLE_BUTTON_SIZE,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n }\n local buttonPos = CYCLE_BUTTON_START:copy()\n local rowCount = 0\n local colCount = 0\n for _, cycle in ipairs(CYCLE_LIST) do\n cycleButtonParams.click_function = \"spawnCycle\" .. cycle\n cycleButtonParams.position = buttonPos\n cycleButtonParams.tooltip = cycle\n self.createButton(cycleButtonParams)\n self.setVar(cycleButtonParams.click_function, function(_, _, _) spawnCycle(cycle) end)\n colCount = colCount + 1\n -- If we've reached the end of a row, shift down and back to the first column\n if colCount \u003e= CYCLE_COLUMN_COUNT then\n buttonPos = CYCLE_BUTTON_START:copy()\n rowCount = rowCount + 1\n colCount = 0\n buttonPos.z = buttonPos.z + CYCLE_BUTTONS_Z_OFFSET * rowCount\n if rowCount == 3 then\n -- Account for two centered buttons on the final row\n buttonPos.x = buttonPos.x + CYCLE_BUTTONS_X_OFFSET / 2\n --[[ Account for centered button on the final row\n buttonPos.x = buttonPos.x + CYCLE_BUTTONS_X_OFFSET\n ]]\n end\n else\n buttonPos.x = buttonPos.x + CYCLE_BUTTONS_X_OFFSET\n end\n end\nend\n\nfunction createClearButton()\n self.createButton({\n function_owner = self,\n click_function = \"deleteAll\",\n position = Vector(0, 0.1, 0.852),\n height = 170,\n width = 750,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n })\nend\n\nfunction createInvestigatorModeButtons()\n local starterMode = starterDeckMode == STARTER_DECK_MODE_STARTERS\n\n self.createButton({\n function_owner = self,\n click_function = \"setCardsOnlyMode\",\n position = Vector(0.251, 0.1, -0.322),\n height = 170,\n width = 760,\n scale = Vector(0.25, 1, 0.25),\n color = starterMode and TRANSPARENT or STARTER_DECK_MODE_SELECTED_COLOR\n })\n self.createButton({\n function_owner = self,\n click_function = \"setStarterDeckMode\",\n position = Vector(0.66, 0.1, -0.322),\n height = 170,\n width = 760,\n scale = Vector(0.25, 1, 0.25),\n color = starterMode and STARTER_DECK_MODE_SELECTED_COLOR or TRANSPARENT\n })\n local checkX = starterMode and 0.52 or 0.11\n self.createButton({\n function_owner = self,\n label = \"✓\",\n click_function = \"doNothing\",\n position = Vector(checkX, 0.11, -0.317),\n height = 0,\n width = 0,\n scale = Vector(0.3, 1, 0.3),\n font_color = { 0, 0, 0 },\n color = { 1, 1, 1 }\n })\nend\n\nfunction toggleHelp(_, playerColor, _)\n if helpVisibleToPlayers[playerColor] then\n helpVisibleToPlayers[playerColor] = nil\n else\n helpVisibleToPlayers[playerColor] = true\n end\n updateHelpVisibility()\nend\n\nfunction updateHelpVisibility()\n local visibility = \"\"\n for player, _ in pairs(helpVisibleToPlayers) do\n if string.len(visibility) \u003e 0 then\n visibility = visibility .. \"|\" .. player\n else\n visibility = player\n end\n end\n self.UI.setAttribute(\"helpText\", \"visibility\", visibility)\n self.UI.setAttribute(\"helpPanel\", \"visibility\", visibility)\n self.UI.setAttribute(\"helpPanel\", \"active\", string.len(visibility) \u003e 0)\nend\n\nfunction setStarterDeckMode()\n starterDeckMode = STARTER_DECK_MODE_STARTERS\n updateStarterModeButtons()\nend\n\nfunction setCardsOnlyMode()\n starterDeckMode = STARTER_DECK_MODE_CARDS_ONLY\n updateStarterModeButtons()\nend\n\nfunction updateStarterModeButtons()\n local buttonCount = #self.getButtons()\n -- Buttons are 0-indexed, so the last three are -1, -2, and -3 from the size\n self.removeButton(buttonCount - 1)\n self.removeButton(buttonCount - 2)\n self.removeButton(buttonCount - 3)\n createInvestigatorModeButtons()\nend\n\n-- Clears the table and updates positions based on scale (should be called before ANY card placement)\nfunction prepareToPlaceCards()\n deleteAll()\n scalePositions()\nend\n\n-- Updates the positions based on the current object scale to ensure the relative layout functions\n-- properly at different scales.\nfunction scalePositions()\n -- Assume scaling is consistent in X and Z dimensions\n local scale = 1 / self.getScale().x\n startPositions = { }\n for key, pos in pairs(START_POSITIONS) do\n -- Because a scaled object means a different global size, using global distance for Z results in\n -- the cards being closer or farther depending on the scale. Leave the Z values and only scale X and Y\n startPositions[key] = Vector(pos)\n startPositions[key].x = startPositions[key].x * scale\n startPositions[key].y = startPositions[key].y * scale\n end\n cardRowOffset = CARD_ROW_OFFSET * scale\n cardGroupOffset = CARD_GROUP_OFFSET * scale\n investigatorPositionShiftRow = Vector(INVESTIGATOR_POSITION_SHIFT_ROW):scale(scale)\n investigatorPositionShiftCol = Vector(INVESTIGATOR_POSITION_SHIFT_COL):scale(scale)\n investigatorCardOffset = Vector(INVESTIGATOR_CARD_OFFSET):scale(scale)\n investigatorSignatureOffset = Vector(INVESTIGATOR_SIGNATURE_OFFSET):scale(scale)\nend\n\n-- Deletes all cards currently placed on the table\nfunction deleteAll()\n spawnBag.recall(true)\nend\n\n-- Spawn an investigator group, based on the current UI setting for either investigators or starter\n-- decks.\n---@param groupName string Name of the group to spawn, matching a key in InvestigatorPanelData\nfunction spawnInvestigatorGroup(groupName)\n local starterMode = starterDeckMode == STARTER_DECK_MODE_STARTERS\n prepareToPlaceCards()\n Wait.frames(function()\n if starterMode then\n spawnStarters(groupName)\n else\n spawnInvestigators(groupName)\n end\n end, 2)\nend\n\n-- Spawn cards for all investigators in the given group. This creates piles for all defined\n-- investigator cards and minicards as well as the signature cards.\n---@param groupName string Name of the group to spawn, matching a key in InvestigatorPanelData\nfunction spawnInvestigators(groupName)\n if INVESTIGATOR_GROUPS[groupName] == nil then\n printToAll(\"No \" .. groupName .. \" data yet\")\n return\n end\n\n local col = 1\n local row = 1\n local investigatorCount = #INVESTIGATOR_GROUPS[groupName]\n local position = getInvestigatorRowStartPos(investigatorCount, row)\n\n for i, investigatorName in ipairs(INVESTIGATOR_GROUPS[groupName]) do\n for _, spawnSpec in ipairs(buildInvestigatorSpawnSpec(investigatorName, INVESTIGATORS[investigatorName], position)) do\n spawnBag.spawn(spawnSpec)\n end\n position:add(investigatorPositionShiftCol)\n col = col + 1\n if col \u003e INVESTIGATOR_MAX_COLS then\n col = 1\n row = row + 1\n position = getInvestigatorRowStartPos(investigatorCount, row)\n end\n end\nend\n\nfunction getInvestigatorRowStartPos(investigatorCount, row)\n local rowStart = Vector(startPositions.investigator)\n rowStart:add(Vector(\n investigatorPositionShiftRow.x * (row - 1),\n investigatorPositionShiftRow.y * (row - 1),\n investigatorPositionShiftRow.z * (row - 1)))\n local investigatorsInRow = math.min(investigatorCount - INVESTIGATOR_MAX_COLS * (row - 1), INVESTIGATOR_MAX_COLS)\n rowStart:add(Vector(\n investigatorPositionShiftCol.x * (INVESTIGATOR_MAX_COLS - investigatorsInRow) / 2,\n investigatorPositionShiftCol.y * (INVESTIGATOR_MAX_COLS - investigatorsInRow) / 2,\n investigatorPositionShiftCol.z * (INVESTIGATOR_MAX_COLS - investigatorsInRow) / 2))\n return rowStart\nend\n\n-- Creates the spawn spec for the investigator's signature cards.\n---@param investigatorName string Name of the investigator, matching a key in InvestigatorPanelData\n---@param investigatorData table Spawn definition for the investigator, retrieved from INVESTIGATORS\n---@param position tts__Vector Where to spawn the minicard; investigagor cards will be placed below\nfunction buildInvestigatorSpawnSpec(investigatorName, investigatorData, position)\n local sigPos = Vector(position):add(investigatorSignatureOffset)\n local spawns = buildCommonSpawnSpec(investigatorName, investigatorData, position)\n table.insert(spawns, {\n name = investigatorName .. \"signatures\",\n cards = investigatorData.signatures,\n globalPos = self.positionToWorld(sigPos),\n rotation = FACE_UP_ROTATION\n })\n\n return spawns\nend\n\n-- Builds the spawn specs for minicards and investigator cards. These are common enough to be\n-- shared, and will only differ in whether they spawn the full stack of possible investigator and\n-- minicards, or only the first of each.\n---@param investigatorName string Name of the investigator, matching a key in InvestigatorPanelData\n---@param investigatorData table Spawn definition for the investigator, retrieved from INVESTIGATORS\n---@param position tts__Vector Where to spawn the minicard; investigagor cards will be placed below\n---@param oneCardOnly? boolean If true, will spawn only the first card in the investigator card\n--- and minicard lists. Otherwise, spawn them all in a deck\nfunction buildCommonSpawnSpec(investigatorName, investigatorData, position, oneCardOnly)\n local cardPos = Vector(position):add(investigatorCardOffset)\n return {\n {\n name = investigatorName .. \"minicards\",\n cards = oneCardOnly and { investigatorData.minicards[1] } or investigatorData.minicards,\n globalPos = self.positionToWorld(position),\n rotation = FACE_UP_ROTATION\n },\n {\n name = investigatorName .. \"cards\",\n cards = oneCardOnly and { investigatorData.cards[1] } or investigatorData.cards,\n globalPos = self.positionToWorld(cardPos),\n rotation = FACE_UP_ROTATION\n }\n }\nend\n\n-- Spawns all starter decks (single minicard and investigator card, plus the starter deck) for\n-- investigators in the given group.\n---@param groupName string Name of the group to spawn, matching a key in InvestigatorPanelData\nfunction spawnStarters(groupName)\n local col = 1\n local row = 1\n local investigatorCount = #INVESTIGATOR_GROUPS[groupName]\n local position = getInvestigatorRowStartPos(investigatorCount, row)\n for _, investigatorName in ipairs(INVESTIGATOR_GROUPS[groupName]) do\n spawnStarterDeck(investigatorName, INVESTIGATORS[investigatorName], position)\n position:add(investigatorPositionShiftCol)\n col = col + 1\n if col \u003e INVESTIGATOR_MAX_COLS then\n col = 1\n row = row + 1\n position = getInvestigatorRowStartPos(investigatorCount, row)\n end\n end\nend\n\n-- Spawns the defined starter deck for the given investigator's.\n---@param investigatorName string Name of the investigator, matching a key in InvestigatorPanelData\nfunction spawnStarterDeck(investigatorName, investigatorData, position)\n for _, spawnSpec in ipairs(buildCommonSpawnSpec(investigatorName, investigatorData, position, true)) do\n spawnBag.spawn(spawnSpec)\n end\n local deckPos = Vector(position):add(investigatorSignatureOffset)\n arkhamDb.getDecklist(\"None\", investigatorData.starterDeck, true, false, false, function(slots)\n local cardIdList = { }\n for id, count in pairs(slots) do\n for i = 1, count do\n table.insert(cardIdList, id)\n end\n end\n spawnBag.spawn({\n name = investigatorName..\"starter\",\n cards = cardIdList,\n globalPos = self.positionToWorld(deckPos),\n rotation = FACE_DOWN_ROTATION\n })\n end)\nend\n-- Clears the currently placed cards, then places cards for the given class and level spread\n---@param cardClass string Class to place (\"Guardian\", \"Seeker\", etc)\n---@param isUpgraded boolean If true, spawn the Level 1-5 cards. Otherwise, Level 0.\nfunction spawnClassCards(cardClass, isUpgraded)\n prepareToPlaceCards()\n Wait.frames(function() placeClassCards(cardClass, isUpgraded) end, 2)\nend\n\n-- Spawn the class cards.\n---@param cardClass string Class to place (\"Guardian\", \"Seeker\", etc)\n---@param isUpgraded boolean If true, spawn the Level 1-5 cards. Otherwise, Level 0.\nfunction placeClassCards(cardClass, isUpgraded)\n local indexReady = allCardsBagApi.isIndexReady()\n if (not indexReady) then\n broadcastToAll(\"Still loading player cards, please try again in a few seconds\", {0.9, 0.2, 0.2})\n return\n end\n local cardIdList = allCardsBagApi.getCardsByClassAndLevel(cardClass, isUpgraded)\n\n local skillList = { }\n local eventList = { }\n local assetList = { }\n for _, cardId in ipairs(cardIdList) do\n local cardMetadata = allCardsBagApi.getCardById(cardId).metadata\n if (cardMetadata.type == \"Skill\") then\n table.insert(skillList, cardId)\n elseif (cardMetadata.type == \"Event\") then\n table.insert(eventList, cardId)\n elseif (cardMetadata.type == \"Asset\") then\n table.insert(assetList, cardId)\n end\n end\n local groupPos = Vector(startPositions.classCards)\n if #skillList \u003e 0 then\n spawnBag.spawn({\n name = cardClass .. (isUpgraded and \"upgraded\" or \"basic\"),\n cards = skillList,\n globalPos = self.positionToWorld(groupPos),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\n groupPos.z = groupPos.z + math.ceil(#skillList / 20) * cardRowOffset + cardGroupOffset\n end\n if #eventList \u003e 0 then\n spawnBag.spawn({\n name = cardClass .. \"event\" .. (isUpgraded and \"upgraded\" or \"basic\"),\n cards = eventList,\n globalPos = self.positionToWorld(groupPos),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\n groupPos.z = groupPos.z + math.ceil(#eventList / 20) * cardRowOffset + cardGroupOffset\n end\n if #assetList \u003e 0 then\n spawnBag.spawn({\n name = cardClass .. \"asset\" .. (isUpgraded and \"upgraded\" or \"basic\"),\n cards = assetList,\n globalPos = self.positionToWorld(groupPos),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\n end\nend\n\n-- Spawns the investigator sets and all cards for the given cycle\n---@param cycle string Name of a cycle, should match the standard used in card metadata\nfunction spawnCycle(cycle)\n prepareToPlaceCards()\n spawnInvestigators(cycle)\n local indexReady = allCardsBagApi.isIndexReady()\n if (not indexReady) then\n broadcastToAll(\"Still loading player cards, please try again in a few seconds\", {0.9, 0.2, 0.2})\n return\n end\n local cycleCardList = allCardsBagApi.getCardsByCycle(cycle)\n local copiedList = { }\n for i, id in ipairs(cycleCardList) do\n copiedList[i] = id\n end\n spawnBag.spawn({\n name = \"cycle\"..cycle,\n cards = copiedList,\n globalPos = self.positionToWorld(startPositions.cycle),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\nend\n\nfunction spawnBonded()\n prepareToPlaceCards()\n spawnBag.spawn({\n name = \"bonded\",\n cards = BONDED_CARD_LIST,\n globalPos = self.positionToWorld(startPositions.classCards),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\nend\n\nfunction spawnUpgradeSheets()\n prepareToPlaceCards()\n spawnBag.spawn({\n name = \"upgradeSheets\",\n cards = UPGRADE_SHEET_LIST,\n globalPos = self.positionToWorld(startPositions.classCards),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\n spawnBag.spawn({\n name = \"servitor\",\n cards = { \"09080-m\" },\n globalPos = self.positionToWorld(startPositions.summonedServitor),\n rotation = FACE_UP_ROTATION,\n })\nend\n\n-- Clears the current cards, and places all basic weaknesses on the table.\nfunction spawnWeaknesses()\n prepareToPlaceCards()\n local indexReady = allCardsBagApi.isIndexReady()\n if (not indexReady) then\n broadcastToAll(\"Still loading player cards, please try again in a few seconds\", {0.9, 0.2, 0.2})\n return\n end\n local weaknessIdList = allCardsBagApi.getUniqueWeaknesses()\n local basicWeaknessList = { }\n local otherWeaknessList = { }\n for i, id in ipairs(weaknessIdList) do\n local cardMetadata = allCardsBagApi.getCardById(id).metadata\n if cardMetadata.basicWeaknessCount ~= nil and cardMetadata.basicWeaknessCount \u003e 0 then\n table.insert(basicWeaknessList, id)\n elseif excludedNonBasicWeaknesses[id] == nil then\n table.insert(otherWeaknessList, id)\n end\n end\n local groupPos = Vector(startPositions.classCards)\n spawnBag.spawn({\n name = \"basicWeaknesses\",\n cards = basicWeaknessList,\n globalPos = self.positionToWorld(groupPos),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\n groupPos.z = groupPos.z + math.ceil(#basicWeaknessList / 20) * cardRowOffset + cardGroupOffset\n spawnBag.spawn({\n name = \"evolvedWeaknesses\",\n cards = EVOLVED_WEAKNESSES,\n globalPos = self.positionToWorld(groupPos),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\n groupPos.z = groupPos.z + math.ceil(#EVOLVED_WEAKNESSES / 20) * cardRowOffset + cardGroupOffset\n spawnBag.spawn({\n name = \"otherWeaknesses\",\n cards = otherWeaknessList,\n globalPos = self.positionToWorld(groupPos),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\nend\n\nfunction spawnRandomWeakness()\n prepareToPlaceCards()\n local weaknessId = allCardsBagApi.getRandomWeaknessId()\n if (weaknessId == nil) then\n broadcastToAll(\"All basic weaknesses are in play!\", {0.9, 0.2, 0.2})\n return\n end\n spawnBag.spawn({\n name = \"randomWeakness\",\n cards = { weaknessId },\n globalPos = self.positionToWorld(startPositions.randomWeakness),\n rotation = FACE_UP_ROTATION,\n })\nend\nend)\n__bundle_register(\"playercards/PlayerCardPanelData\", function(require, _LOADED, __bundle_register, __bundle_modules)\nBONDED_CARD_LIST = {\n\t\"05314\", -- Soothing Melody\n\t\"06277\", -- Wish Eater\n\t\"06019\", -- Bloodlust\n\t\"06022\", -- Pendant of the Queen\n\t\"05317\", -- Blood-rite\n\t\"06113\", -- Essence of the Dream\n\t\"06028\", -- Stars Are Right\n\t\"06025\", -- Guardian of the Crystallizer\n\t\"06283\", -- Unbound Beast\n\t\"06032\", -- Zeal\n\t\"06031\", -- Hope\n\t\"06033\", -- Augur\n\t\"06331\", -- Dream Parasite\n\t\"06015a\", -- Dream-Gate\n\t\"10006\",\t\t-- Aetheric Current (Yuggoth)\n\t\"10007\",\t\t-- Aetheric Current (Yoth)\n\t\"10036\",\t\t-- Blade of Yoth\n\t\"10039\",\t\t-- Evanescent Ascension\n\t\"10045\", -- Uncanny Growth\n\t\"10063\",\t\t-- Bianca\n\t\"10086\",\t\t-- Rot\n\t\"10087\",\t\t-- Rot\n\t\"10088\",\t\t-- Rot\n\t\"10089\",\t\t-- Rot\n\t\"10090\",\t\t-- Rot\n\t\"10106\",\t\t-- Keeper of the Key\n\t\"10107\",\t\t-- Servant of Brass\n\t\"10134\",\t\t-- Twilight Diadem\n}\n\nUPGRADE_SHEET_LIST = {\n\t\"09040-c\", -- Alchemical Distillation\n\t\"09023-c\", -- Custom Modifications\n\t\"09059-c\", -- Damning Testimony\n\t\"09041-c\", -- Emperical Hypothesis\n\t\"09060-c\", -- Friends in Low Places\n\t\"09101-c\", -- Grizzled\n\t\"09061-c\", -- Honed Instinct\n\t\"09021-c\", -- Hunter's Armor\n\t\"09119-c\", -- Hyperphysical Shotcaster\n\t\"09079-c\", -- Living Ink\n\t\"09100-c\", -- Makeshift Trap\n\t\"09099-c\", -- Pocket Multi Tool\n\t\"09081-c\", -- Power Word\n\t\"09081-t-c\", -- Power Word (Taboo)\n\t\"09022-c\", -- Runic Axe\n\t\"09022-t-c\", -- Runic Axe (Taboo)\n\t\"09080-c\", -- Summoned Servitor\n\t\"09042-c\", -- Raven's Quill\n}\n\nEVOLVED_WEAKNESSES = {\n\t\"04039\",\n\t\"04041\",\n\t\"04042\",\n\t\"53014\",\n\t\"53015\",\n}\n\n------------------ START INVESTIGATOR DATA DEFINITION ------------------\nINVESTIGATOR_GROUPS = {\n [\"Guardian\"] = {\n \"Roland Banks\",\n \t\"Zoey Samaras\",\n \t\"Mark Harrigan\",\n \t\"Leo Anderson\",\n \t\"Carolyn Fern\",\n \t\"Tommy Muldoon\",\n \t\"Nathaniel Cho\",\n \t\"Sister Mary\",\n \t\"Daniela Reyes\",\n \t\"Carson Sinclair\",\n\t\t\"Wilson Richards\"\n },\n [\"Seeker\"] = {\n \"Daisy Walker\",\n \t\"Rex Murphy\",\n \t\"Minh Thi Phan\",\n \t\"Ursula Downs\",\n \t\"Joe Diamond\",\n \t\"Mandy Thompson\",\n \t\"Harvey Walters\",\n \t\"Amanda Sharpe\",\n \t\"Norman Withers\",\n \t\"Vincent Lee\",\n\t\t\"Kate Winthrop\"\n },\n [\"Rogue\"] = {\n \t\"\\\"Skids\\\" O'Toole\",\n \t\"Jenny Barnes\",\n \t\"Sefina Rousseau\",\n \t\"Finn Edwards\",\n \t\"Preston Fairmont\",\n \t\"Tony Morgan\",\n \t\"Winifred Habbamock\",\n \t\"Trish Scarborough\",\n \t\"Monterey Jack\",\n \t\"Kymani Jones\",\n\t\t\"Alessandra Zorzi\"\n },\n [\"Mystic\"] = {\n \t\"Agnes Baker\",\n \t\"Jim Culver\",\n \t\"Akachi Onyele\",\n \t\"Father Mateo\",\n \t\"Diana Stanley\",\n \t\"Marie Lambeau\",\n \t\"Luke Robinson\",\n \t\"Jacqueline Fine\",\n \t\"Dexter Drake\",\n \t\"Lily Chen\",\n \t\"Amina Zidane\",\n \t\"Gloria Goldberg\",\n\t\t\"Kōhaku Narukami\"\n },\n [\"Survivor\"] = {\n \t\"Wendy Adams\",\n \t\"\\\"Ashcan\\\" Pete\",\n \t\"William Yorick\",\n \t\"Calvin Wright\",\n \t\"Rita Young\",\n \t\"Patrice Hathaway\",\n \t\"Stella Clark\",\n \t\"Silas Marsh\",\n \t\"Bob Jenkins\",\n \t\"Darrell Simmons\",\n\t\t\"Hank Samson\"\n },\n [\"Neutral\"] = {\n \t\"Lola Hayes\",\n \t\"Charlie Kane\",\n \t\"Subject 5U-21\"\n },\n [\"Core\"] = {\n \"Roland Banks\",\n \"Daisy Walker\",\n \"\\\"Skids\\\" O'Toole\",\n \"Agnes Baker\",\n \"Wendy Adams\"\n },\n [\"The Dunwich Legacy\"] = {\n \t\"Zoey Samaras\",\n \t\"Rex Murphy\",\n \t\"Jenny Barnes\",\n \t\"Jim Culver\",\n \t\"\\\"Ashcan\\\" Pete\"\n },\n [\"The Path to Carcosa\"] = {\n \t\"Mark Harrigan\",\n \t\"Minh Thi Phan\",\n \t\"Sefina Rousseau\",\n \t\"Akachi Onyele\",\n \t\"William Yorick\",\n \t\"Lola Hayes\"\n },\n [\"The Forgotten Age\"] = {\n \t\"Leo Anderson\",\n \t\"Ursula Downs\",\n \t\"Finn Edwards\",\n \t\"Father Mateo\",\n \t\"Calvin Wright\"\n },\n [\"The Circle Undone\"] = {\n \t\"Carolyn Fern\",\n \t\"Joe Diamond\",\n \t\"Preston Fairmont\",\n \t\"Diana Stanley\",\n \t\"Rita Young\",\n \t\"Marie Lambeau\"\n },\n [\"The Dream-Eaters\"] = {\n \t\"Tommy Muldoon\",\n \t\"Mandy Thompson\",\n \t\"Tony Morgan\",\n \t\"Luke Robinson\",\n \t\"Patrice Hathaway\"\n },\n [\"Investigator Packs\"] = {\n \t\"Nathaniel Cho\",\n \t\"Harvey Walters\",\n \t\"Winifred Habbamock\",\n \t\"Jacqueline Fine\",\n \t\"Stella Clark\",\n \t\"Gloria Goldberg\"\n },\n [\"The Innsmouth Conspiracy\"] = {\n \t\"Sister Mary\",\n \t\"Amanda Sharpe\",\n \t\"Trish Scarborough\",\n \t\"Dexter Drake\",\n \t\"Silas Marsh\"\n },\n [\"Edge of the Earth\"] = {\n \t\"Daniela Reyes\",\n \t\"Norman Withers\",\n \t\"Monterey Jack\",\n \t\"Lily Chen\",\n \t\"Bob Jenkins\"\n },\n [\"The Scarlet Keys\"] = {\n \t\"Carson Sinclair\",\n \t\"Vincent Lee\",\n \t\"Kymani Jones\",\n \t\"Amina Zidane\",\n \t\"Darrell Simmons\",\n \t\"Charlie Kane\"\n },\n\t[\"The Feast of Hemlock Vale\"] = {\n\t\t\"Wilson Richards\",\n\t\t\"Kate Winthrop\",\n\t\t\"Alessandra Zorzi\",\n\t\t\"Kōhaku Narukami\",\n\t\t\"Hank Samson\"\n\t}\n}\n\nINVESTIGATORS = {}\n-- Core Box\nINVESTIGATORS[\"Roland Banks\"] = {\n\tcards = { \"01001\", \"01001-p\", \"01001-pf\", \"01001-pb\" },\n\tminicards = { \"01001-m\" },\n\tsignatures = { \"01006\", \"01007\", \"90030\", \"90031\", \"90025\", \"90026\", \"90027\", \"90028\", \"90029\", \"98005\", \"98006\" },\n\tstarterDeck = \"2624931\"\n}\nINVESTIGATORS[\"Daisy Walker\"] = {\n\tcards = { \"01002\", \"01002-p\", \"01002-pf\", \"01002-pb\" },\n\tminicards = { \"01002-m\" },\n\tsignatures = { \"01008\", \"01009\", \"90002\", \"90003\" },\n\tstarterDeck = \"2624938\"\n}\nINVESTIGATORS[\"\\\"Skids\\\" O'Toole\"] = {\n\tcards = { \"01003\", \"01003-p\", \"01003-pf\", \"01003-pb\" },\n\tminicards = { \"01003-m\" },\n\tsignatures = { \"01010\", \"01011\", \"90009\", \"90010\" },\n\tstarterDeck = \"2624940\"\n}\nINVESTIGATORS[\"Agnes Baker\"] = {\n\tcards = { \"01004\", \"01004-p\", \"01004-pf\", \"01004-pb\" },\n\tminicards = { \"01004-m\" },\n\tsignatures = { \"01012\", \"01013\", \"90018\", \"90019\" },\n\tstarterDeck = \"2624944\"\n}\nINVESTIGATORS[\"Wendy Adams\"] = {\n\tcards = { \"01005\", \"01005-p\", \"01005-pf\", \"01005-pb\" },\n\tminicards = { \"01005-m\" },\n\tsignatures = { \"01014\", \"01015\", \"01515\", \"90039\", \"90040\", \"90038\" },\n\tstarterDeck = \"2624949\"\n}\n-- The Dunwich Legacy\nINVESTIGATORS[\"Zoey Samaras\"] = {\n\tcards = { \"02001\", \"02001-p\", \"02001-pf\", \"02001-pb\" },\n\tminicards = { \"02001-m\" },\n\tsignatures = { \"02006\", \"02007\", \"90060\", \"90061\" },\n\tstarterDeck = \"2624950\"\n}\nINVESTIGATORS[\"Rex Murphy\"] = {\n\tcards = { \"02002\", \"02002-t\" },\n\tminicards = { \"02002-m\" },\n\tsignatures = { \"02008\", \"02009\" },\n\tstarterDeck = \"2624958\"\n}\nINVESTIGATORS[\"Jenny Barnes\"] = {\n\tcards = { \"02003\" },\n\tminicards = { \"02003-m\" },\n\tsignatures = { \"02010\", \"02011\", \"98002\", \"98003\" },\n\tstarterDeck = \"2624961\"\n}\nINVESTIGATORS[\"Jim Culver\"] = {\n\tcards = { \"02004\", \"02004-p\", \"02004-pf\", \"02004-pb\" },\n\tminicards = { \"02004-m\" },\n\tsignatures = { \"02012\", \"02013\", \"90050\", \"90051\", \"90052\", \"90053\" },\n\tstarterDeck = \"2624965\"\n}\nINVESTIGATORS[\"\\\"Ashcan\\\" Pete\"] = {\n\tcards = { \"02005\", \"02005-p\", \"02005-pf\", \"02005-pb\" },\n\tminicards = { \"02005-m\" },\n\tsignatures = { \"02014\", \"02015\", \"90047\", \"90048\" },\n\tstarterDeck = \"2624969\"\n}\n-- The Path to Carcosa\nINVESTIGATORS[\"Mark Harrigan\"] = {\n\tcards = { \"03001\" },\n\tminicards = { \"03001-m\" },\n\tsignatures = { \"03007\", \"03008\", \"03009\" },\n\tstarterDeck = \"2624975\"\n}\nINVESTIGATORS[\"Minh Thi Phan\"] = {\n\tcards = { \"03002\" },\n\tminicards = { \"03002-m\" },\n\tsignatures = { \"03010\", \"03011\" },\n\tstarterDeck = \"2624979\"\n}\nINVESTIGATORS[\"Sefina Rousseau\"] = {\n\tcards = { \"03003\" },\n\tminicards = { \"03003-m\" },\n\tsignatures = { \"03012\", \"03012\", \"03012\", \"03013\" },\n\tstarterDeck = \"2624981\"\n}\nINVESTIGATORS[\"Akachi Onyele\"] = {\n\tcards = { \"03004\" },\n\tminicards = { \"03004-m\" },\n\tsignatures = { \"03014\", \"03015\" },\n\tstarterDeck = \"2624984\"\n}\nINVESTIGATORS[\"William Yorick\"] = {\n\tcards = { \"03005\" },\n\tminicards = { \"03005-m\" },\n\tsignatures = { \"03016\", \"03017\" },\n\tstarterDeck = \"2624988\"\n}\nINVESTIGATORS[\"Lola Hayes\"] = {\n\tcards = { \"03006\", \"03006-t\" },\n\tminicards = { \"03006-m\" },\n\tsignatures = { \"03018\", \"03018\", \"03019\", \"03019\", \"03019-t\", \"03019-t\" },\n\tstarterDeck = \"2624990\"\n}\n-- The Forgotten Age\nINVESTIGATORS[\"Leo Anderson\"] = {\n\tcards = { \"04001\" },\n\tminicards = { \"04001-m\" },\n\tsignatures = { \"04006\", \"04007\" },\n\tstarterDeck = \"2624994\"\n}\nINVESTIGATORS[\"Ursula Downs\"] = {\n\tcards = { \"04002\" },\n\tminicards = { \"04002-m\" },\n\tsignatures = { \"04008\", \"04009\" },\n\tstarterDeck = \"2625000\"\n}\nINVESTIGATORS[\"Finn Edwards\"] = {\n\tcards = { \"04003\" },\n\tminicards = { \"04003-m\" },\n\tsignatures = { \"04010\", \"04011\", \"04012\" },\n\tstarterDeck = \"2625003\"\n}\nINVESTIGATORS[\"Father Mateo\"] = {\n\tcards = { \"04004\" },\n\tminicards = { \"04004-m\" },\n\tsignatures = { \"04013\", \"04014\" },\n\tstarterDeck = \"2625005\"\n}\nINVESTIGATORS[\"Calvin Wright\"] = {\n\tcards = { \"04005\" },\n\tminicards = { \"04005-m\" },\n\tsignatures = { \"04015\", \"04016\" },\n\tstarterDeck = \"2625007\"\n}\n-- The Circle Undone\nINVESTIGATORS[\"Carolyn Fern\"] = {\n\tcards = { \"05001\" },\n\tminicards = { \"05001-m\" },\n\tsignatures = { \"05007\", \"05008\", \"98011\", \"98012\" },\n\tstarterDeck = \"2626342\"\n}\nINVESTIGATORS[\"Joe Diamond\"] = {\n\tcards = { \"05002\" },\n\tminicards = { \"05002-m\" },\n\tsignatures = { \"05009\", \"05010\" },\n\tstarterDeck = \"2626347\"\n}\nINVESTIGATORS[\"Preston Fairmont\"] = {\n\tcards = { \"05003\" },\n\tminicards = { \"05003-m\" },\n\tsignatures = { \"05011\", \"05012\" },\n\tstarterDeck = \"2626365\"\n}\nINVESTIGATORS[\"Diana Stanley\"] = {\n\tcards = { \"05004\" },\n\tminicards = { \"05004-m\" },\n\tsignatures = { \"05013\", \"05014\", \"05015\" },\n\tstarterDeck = \"2626385\"\n}\nINVESTIGATORS[\"Rita Young\"] = {\n\tcards = { \"05005\" },\n\tminicards = { \"05005-m\" },\n\tsignatures = { \"05016\", \"05017\" },\n\tstarterDeck = \"2626387\"\n}\nINVESTIGATORS[\"Marie Lambeau\"] = {\n\tcards = { \"05006\" },\n\tminicards = { \"05006-m\" },\n\tsignatures = { \"05018\", \"05019\" },\n\tstarterDeck = \"2626395\"\n}\n-- The Dream-Eaters\nINVESTIGATORS[\"Tommy Muldoon\"] = {\n\tcards = { \"06001\" },\n\tminicards = { \"06001-m\" },\n\tsignatures = { \"06006\", \"06007\" },\n\tstarterDeck = \"2626402\"\n}\nINVESTIGATORS[\"Mandy Thompson\"] = {\n\tcards = { \"06002\", \"06002-t\" },\n\tminicards = { \"06002-m\" },\n\tsignatures = { \"06008\", \"06008\", \"06008\", \"06009\" },\n\tstarterDeck = \"2626410\"\n}\nINVESTIGATORS[\"Tony Morgan\"] = {\n\tcards = { \"06003\" },\n\tminicards = { \"06003-m\" },\n\tsignatures = { \"06010\", \"06011\", \"06011\", \"06012\" },\n\tstarterDeck = \"2626446\"\n}\nINVESTIGATORS[\"Luke Robinson\"] = {\n\tcards = { \"06004\" },\n\tminicards = { \"06004-m\" },\n\tsignatures = { \"06013\", \"06014\", \"06015\" },\n\tstarterDeck = \"2626452\"\n}\nINVESTIGATORS[\"Patrice Hathaway\"] = {\n\tcards = { \"06005\" },\n\tminicards = { \"06005-m\" },\n\tsignatures = { \"06016\", \"06017\" },\n\tstarterDeck = \"2626461\"\n}\n-- Starter Decks\nINVESTIGATORS[\"Nathaniel Cho\"] = {\n\tcards = { \"60101\" },\n\tminicards = { \"60101-m\" },\n\tsignatures = { \"60102\", \"60103\" },\n\tstarterDeck = \"2643925\"\n}\nINVESTIGATORS[\"Harvey Walters\"] = {\n\tcards = { \"60201\" },\n\tminicards = { \"60201-m\" },\n\tsignatures = { \"60202\", \"60203\" },\n\tstarterDeck = \"2643928\"\n}\nINVESTIGATORS[\"Winifred Habbamock\"] = {\n\tcards = { \"60301\" },\n\tminicards = { \"60301-m\" },\n\tsignatures = { \"60302\", \"60303\" },\n\tstarterDeck = \"2643931\"\n}\nINVESTIGATORS[\"Jacqueline Fine\"] = {\n\tcards = { \"60401\" },\n\tminicards = { \"60401-m\" },\n\tsignatures = { \"60402\", \"60403\" },\n\tstarterDeck = \"2643932\"\n}\nINVESTIGATORS[\"Stella Clark\"] = {\n\tcards = { \"60501\" },\n\tminicards = { \"60501-m\" },\n\tsignatures = { \"60502\", \"60502\", \"60502\", \"60503\" },\n\tstarterDeck = \"2643934\"\n}\n-- The Innsmouth Conspiracy\nINVESTIGATORS[\"Sister Mary\"] = {\n\tcards = { \"07001\" },\n\tminicards = { \"07001-m\" },\n\tsignatures = { \"07006\", \"07007\" },\n\tstarterDeck = \"2626464\"\n}\nINVESTIGATORS[\"Amanda Sharpe\"] = {\n\tcards = { \"07002\" },\n\tminicards = { \"07002-m\" },\n\tsignatures = { \"07008\", \"07009\" },\n\tstarterDeck = \"2626469\"\n}\nINVESTIGATORS[\"Trish Scarborough\"] = {\n\tcards = { \"07003\", \"07003-t\" },\n\tminicards = { \"07003-m\" },\n\tsignatures = { \"07010\", \"07011\" },\n\tstarterDeck = \"2626479\"\n}\nINVESTIGATORS[\"Dexter Drake\"] = {\n\tcards = { \"07004\" },\n\tminicards = { \"07004-m\" },\n\tsignatures = { \"07012\", \"07013\", \"98017\", \"98018\" },\n\tstarterDeck = \"2626672\"\n}\nINVESTIGATORS[\"Silas Marsh\"] = {\n\tcards = { \"07005\" },\n\tminicards = { \"07005-m\" },\n\tsignatures = { \"07014\", \"07015\", \"07016\", \"98014\", \"98015\" },\n\tstarterDeck = \"2626685\"\n}\n-- Edge of the Earth\nINVESTIGATORS[\"Daniela Reyes\"] = {\n\tcards = { \"08001\" },\n\tminicards = { \"08001-m\" },\n\tsignatures = { \"08002\", \"08003\" },\n\tstarterDeck = \"2634588\"\n}\nINVESTIGATORS[\"Norman Withers\"] = {\n\tcards = { \"08004\" },\n\tminicards = { \"08004-m\" },\n\tsignatures = { \"08005\", \"08006\", \"98008\", \"98009\" },\n\tstarterDeck = \"2634603\"\n}\nINVESTIGATORS[\"Monterey Jack\"] = {\n\tcards = { \"08007\", \"08007-p\", \"08007-pf\", \"08007-pb\" },\n\tminicards = { \"08007-m\" },\n\tsignatures = { \"08008\", \"08009\", \"90063\", \"90064\" },\n\tstarterDeck = \"2634652\"\n}\nINVESTIGATORS[\"Lily Chen\"] = {\n\tcards = { \"08010\" },\n\tminicards = { \"08010-m\" },\n\tsignatures = { \"08011a\", \"08012a\", \"08013a\", \"08014a\", \"08015\", \"08015\", \"08015\", \"08015\" },\n\tstarterDeck = \"2634658\"\n}\nINVESTIGATORS[\"Bob Jenkins\"] = {\n\tcards = { \"08016\" },\n\tminicards = { \"08016-m\" },\n\tsignatures = { \"08017\", \"08018\" },\n\tstarterDeck = \"2634643\"\n}\n-- The Scarlet Keys\nINVESTIGATORS[\"Carson Sinclair\"] = {\n\tcards = { \"09001\" },\n\tminicards = { \"09001-m\" },\n\tsignatures = { \"09002\", \"09002\", \"09003\" },\n\tstarterDeck = \"2634667\"\n}\nINVESTIGATORS[\"Vincent Lee\"] = {\n\tcards = { \"09004\" },\n\tminicards = { \"09004-m\" },\n\tsignatures = { \"09005\", \"09006\", \"09006\", \"09006\", \"09006\", \"09007\" },\n\tstarterDeck = \"2634675\"\n}\nINVESTIGATORS[\"Kymani Jones\"] = {\n\tcards = { \"09008\" },\n\tminicards = { \"09008-m\" },\n\tsignatures = { \"09009\", \"09010\" },\n\tstarterDeck = \"2634701\"\n}\nINVESTIGATORS[\"Amina Zidane\"] = {\n\tcards = { \"09011\" },\n\tminicards = { \"09011-m\" },\n\tsignatures = { \"09012\", \"09013\", \"09014\" },\n\tstarterDeck = \"2634697\"\n}\nINVESTIGATORS[\"Darrell Simmons\"] = {\n\tcards = { \"09015\" },\n\tminicards = { \"09015-m\" },\n\tsignatures = { \"09016\", \"09017\" },\n\tstarterDeck = \"2634757\"\n}\nINVESTIGATORS[\"Charlie Kane\"] = {\n\tcards = { \"09018\" },\n\tminicards = { \"09018-m\" },\n\tsignatures = { \"09019\", \"09020\" },\n\tstarterDeck = \"2634706\"\n}\n-- The Feast of Hemlock Vale\nINVESTIGATORS[\"Wilson Richards\"] = {\n\tcards = { \"10001\" },\n\tminicards = { \"10001-m\" },\n\tsignatures = { \"10002\", \"10003\" },\n\tstarterDeck = \"2634667\" --carson deck as placeholder\n}\nINVESTIGATORS[\"Kate Winthrop\"] = {\n\tcards = { \"10004\" },\n\tminicards = { \"10004-m\" },\n\tsignatures = { \"10005\", \"10006\", \"10007\", \"10008\" },\n\tstarterDeck = \"2643928\" --harvey deck as placeholder\n}\nINVESTIGATORS[\"Alessandra Zorzi\"] = {\n\tcards = { \"10009\" },\n\tminicards = { \"10009-m\" },\n\tsignatures = { \"10010\", \"10010\", \"10010\", \"10011\" },\n\tstarterDeck = \"2643931\" --winifred deck as placeholder\n}\nINVESTIGATORS[\"Kōhaku Narukami\"] = {\n\tcards = { \"10012\" },\n\tminicards = { \"10012-m\" },\n\tsignatures = { \"10013\", \"10014\" },\n\tstarterDeck = \"2636199\" --gloria deck as placeholder\n}\nINVESTIGATORS[\"Hank Samson\"] = {\n\tcards = { \"10015\", \"10015-b1\", \"10015-b2\" },\n\tminicards = { \"10015-m\" },\n\tsignatures = { \"10017\", \"10018\"},\n\tstarterDeck = \"2643934\" --stella deck as placeholder\n}\n-- PnP content\nINVESTIGATORS[\"Subject 5U-21\"] = {\n\tcards = { \"89001\" },\n\tminicards = { \"89001-m\" },\n\tsignatures = { \"89002\", \"89003\", \"89003\", \"89003\", \"89004\", \"89004\", \"89004\", \"89005\" },\n\tstarterDeck = \"2624990\" -- Lola's deck id until Suzi is on ArkhamDB\n}\n-- Promo content\nINVESTIGATORS[\"Gloria Goldberg\"] = {\n\tcards = { \"98019\" },\n\tminicards = { \"98019-m\" },\n\tsignatures = { \"98020\", \"98021\" },\n\tstarterDeck = \"2636199\"\n}\n------------------ END INVESTIGATOR DATA DEFINITION ------------------\nend)\n__bundle_register(\"playercards/PlayerCardSpawner\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Amount to shift for the next card (zShift) or next row of cards (xShift)\n-- Note that the table rotation is weird, and the X axis is vertical while the\n-- Z axis is horizontal\nlocal SPREAD_Z_SHIFT = -2.3\nlocal SPREAD_X_SHIFT = -3.66\n\nSpawner = { }\n\n-- Spawns a list of cards at the given position/rotation. This will separate cards by size -\n-- investigator, standard, and mini, spawning them in that order with larger cards on bottom. If\n-- there are different types, the provided callback will be called once for each type as it spawns\n-- either a card or deck.\n---@param cardList table A list of Player Card data structures (data/metadata)\n---@param pos tts__Vector table where the cards should be spawned (global)\n---@param rot tts__Vector table for the orientation of the spawned cards (global)\n---@param sort boolean True if this list of cards should be sorted before spawning\n---@param callback? function Callback to be called after the card/deck spawns.\nSpawner.spawnCards = function(cardList, pos, rot, sort, callback)\n if (sort) then\n table.sort(cardList, Spawner.cardComparator)\n end\n\n local miniCards = { }\n local standardCards = { }\n local investigatorCards = { }\n\n for _, card in ipairs(cardList) do\n if (card.metadata.type == \"Investigator\") then\n table.insert(investigatorCards, card)\n elseif (card.metadata.type == \"Minicard\") then\n table.insert(miniCards, card)\n else\n table.insert(standardCards, card)\n end\n end\n -- Spawn each of the three types individually. Each Y position shift accounts for the thickness\n -- of the spawned deck\n local position = { x = pos.x, y = pos.y, z = pos.z }\n Spawner.spawn(investigatorCards, position, rot, callback)\n\n position.y = position.y + (#investigatorCards + #standardCards) * 0.07\n Spawner.spawn(standardCards, position, rot, callback)\n\n position.y = position.y + (#standardCards + #miniCards) * 0.07\n Spawner.spawn(miniCards, position, rot, callback)\nend\n\nSpawner.spawnCardSpread = function(cardList, startPos, maxCols, rot, sort, callback)\n if (sort) then\n table.sort(cardList, Spawner.cardComparator)\n end\n\n local position = { x = startPos.x, y = startPos.y, z = startPos.z }\n -- Special handle the first row if we have less than a full single row, but only if there's a\n -- reasonable max column count. Single-row spreads will send a large value for maxCols\n if maxCols \u003c 100 and #cardList \u003c maxCols then\n position.z = startPos.z + ((maxCols - #cardList) / 2 * SPREAD_Z_SHIFT)\n end\n local cardsInRow = 0\n local rows = 0\n for _, card in ipairs(cardList) do\n Spawner.spawn({ card }, position, rot, callback)\n position.z = position.z + SPREAD_Z_SHIFT\n cardsInRow = cardsInRow + 1\n if cardsInRow \u003e= maxCols then\n rows = rows + 1\n local cardsForRow = #cardList - rows * maxCols\n if cardsForRow \u003e maxCols then\n cardsForRow = maxCols\n end\n position.z = startPos.z + ((maxCols - cardsForRow) / 2 * SPREAD_Z_SHIFT)\n position.x = position.x + SPREAD_X_SHIFT\n cardsInRow = 0\n end\n end\nend\n\n-- Spawn a specific list of cards. This method is for internal use and should not be called\n-- directly, use spawnCards instead.\n---@param cardList table A list of Player Card data structures (data/metadata)\n---@param pos table Position where the cards should be spawned (global)\n---@param rot table Rotation for the orientation of the spawned cards (global)\n---@param callback? function callback to be called after the card/deck spawns.\nSpawner.spawn = function(cardList, pos, rot, callback)\n if #cardList == 0 then return end\n\n -- Spawn a single card directly\n if #cardList == 1 then\n -- handle sideways card\n if cardList[1].data.SidewaysCard then\n rot = { rot.x, rot.y - 90, rot.z }\n end\n spawnObjectData({\n data = cardList[1].data,\n position = pos,\n rotation = rot,\n callback_function = callback\n })\n return\n end\n\n -- For multiple cards, construct a deck and spawn that\n local deck = Spawner.buildDeckDataTemplate()\n\n -- Decks won't inherently scale to the cards in them. The card list being spawned should be all\n -- the same type/size by this point, so use the first card to set the size\n deck.Transform = {\n scaleX = cardList[1].data.Transform.scaleX,\n scaleY = 1,\n scaleZ = cardList[1].data.Transform.scaleZ\n }\n\n local sidewaysDeck = true\n for _, spawnCard in ipairs(cardList) do\n Spawner.addCardToDeck(deck, spawnCard.data)\n -- set sidewaysDeck to false if any card is not a sideways card\n sidewaysDeck = (sidewaysDeck and spawnCard.data.SidewaysCard)\n end\n\n -- set the alt view angle for sideways decks\n if sidewaysDeck then\n deck.AltLookAngle = { x = 0, y = 180, z = 90 }\n rot = { rot.x, rot.y - 90, rot.z }\n end\n\n spawnObjectData({\n data = deck,\n position = pos,\n rotation = rot,\n callback_function = callback\n })\nend\n\n-- Inserts a card into the given deck. This does three things:\n-- 1. Add the card's data to ContainedObjects\n-- 2. Add the card's ID (the TTS CardID, not the Arkham ID) to the deck's\n-- ID list. Note that the deck's ID list is \"DeckIDs\" even though it\n-- contains a list of card Ids\n-- 3. Extract the card's CustomDeck table and add it to the deck. The deck's\n-- \"CustomDeck\" field is a list of all CustomDecks used by cards within the\n-- deck, keyed by the DeckID and referencing the custom deck table\n---@param deck table TTS deck data structure to add to\n---@param cardData table Data for the card to be inserted\nSpawner.addCardToDeck = function(deck, cardData)\n for customDeckId, customDeckData in pairs(cardData.CustomDeck) do\n if (deck.CustomDeck[customDeckId] == nil) then\n -- CustomDeck not added to deck yet, add it\n deck.CustomDeck[customDeckId] = customDeckData\n elseif (deck.CustomDeck[customDeckId].FaceURL == customDeckData.FaceURL) then\n -- CustomDeck for this card matches the current one for the deck, do nothing\n else\n -- CustomDeck data conflict\n local newDeckId = nil\n for deckId, customDeck in pairs(deck.CustomDeck) do\n if (customDeckData.FaceURL == customDeck.FaceURL) then\n newDeckId = deckId\n end\n end\n if (newDeckId == nil) then\n -- No non-conflicting custom deck for this card, add a new one\n newDeckId = Spawner.findNextAvailableId(deck.CustomDeck, \"1000\")\n deck.CustomDeck[newDeckId] = customDeckData\n end\n -- Update the card with the new CustomDeck info\n cardData.CardID = newDeckId..string.sub(cardData.CardID, 5)\n cardData.CustomDeck[customDeckId] = nil\n cardData.CustomDeck[newDeckId] = customDeckData\n break\n end\n end\n table.insert(deck.ContainedObjects, cardData)\n table.insert(deck.DeckIDs, cardData.CardID)\nend\n\n-- Create an empty deck data table which can have cards added to it. This\n-- creates a new table on each call without using metatables or previous\n-- definitions because we can't be sure that TTS doesn't modify the structure\n---@return table deck Table containing the minimal TTS deck data structure\nSpawner.buildDeckDataTemplate = function()\n local deck = {}\n deck.Name = \"Deck\"\n\n -- Card data. DeckIDs and CustomDeck entries will be built from the cards\n deck.ContainedObjects = {}\n deck.DeckIDs = {}\n deck.CustomDeck = {}\n\n -- Transform is required, Position and Rotation will be overridden by the spawn call so can be omitted here\n deck.Transform = {\n scaleX = 1,\n scaleY = 1,\n scaleZ = 1,\n }\n\n return deck\nend\n\n-- Returns the first ID which does not exist in the given table, starting at startId and increasing\n---@param objectTable table keyed by strings which are numbers\n---@param startId string possible ID.\n---@return string id \u003e= startId\nSpawner.findNextAvailableId = function(objectTable, startId)\n local id = startId\n while (objectTable[id] ~= nil) do\n id = tostring(tonumber(id) + 1)\n end\n return id\nend\n\n-- Get the PBCN (Permanent/Bonded/Customizable/Normal) value from the given metadata.\n---@return number PBCN 1 for Permanent, 2 for Bonded or 4 for Normal. The actual values are\n-- irrelevant as they provide only grouping and the order between them doesn't matter.\nSpawner.getpbcn = function(metadata)\n if metadata.permanent then\n return 1\n elseif metadata.bonded_to ~= nil then\n return 2\n else -- Normal card\n return 3\n end\nend\n\n-- Comparison function used to sort the cards in a deck. Groups bonded or\n-- permanent cards first, then sorts within theose types by name/subname.\n-- Normal cards will sort in standard alphabetical order, while\n-- permanent/bonded/customizable will be in reverse alphabetical order.\n--\n-- Since cards spawn in the order provided by this comparator, with the first\n-- cards ending up at the bottom of a pile, this ordering will spawn in reverse\n-- alphabetical order. This presents the cards in order for non-face-down\n-- areas, and presents them in order when Searching the face-down deck.\nSpawner.cardComparator = function(card1, card2)\n local pbcn1 = Spawner.getpbcn(card1.metadata)\n local pbcn2 = Spawner.getpbcn(card2.metadata)\n if pbcn1 ~= pbcn2 then\n return pbcn1 \u003e pbcn2\n end\n if pbcn1 == 3 then\n if card1.data.Nickname ~= card2.data.Nickname then\n return card1.data.Nickname \u003c card2.data.Nickname\n end\n return card1.data.Description \u003c card2.data.Description\n else\n if card1.data.Nickname ~= card2.data.Nickname then\n return card1.data.Nickname \u003e card2.data.Nickname\n end\n return card1.data.Description \u003e card2.data.Description\n end\nend\nend)\n__bundle_register(\"playercards/SpawnBag\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/PlayerCardSpawner\")\n\n-- Allows spawning of defined lists of cards which will be created from the template in the All\n-- Player Cards bag. SpawnBag.spawn will create objects based on a table definition, while\n-- SpawnBag.recall will clean them all up. Recall will be limited to a small area around the\n-- spawned objects. Objects moved out of this area will not be cleaned up.\n--\n-- SpawnSpec: Spawning requires a spawn specification with the following structure:\n-- {\n-- name: Name of this spawn content, used for internal tracking. Multiple specs can be spawned,\n-- but each requires a separate name\n-- cards: A list of card IDs to be spawned\n-- globalPos: Where the spawned objects should be placed, in global coordinates. This should be\n-- a valid Vector with x, y, and z defined, e.g. { x = 5, y = 1, z = 15 }\n-- rotation: Rotation for the spawned objects. X=180 should be used for face down items. As with\n-- globalPos, this should be a valid Vector with x, y, and z defined\n-- spread: Optional Boolean. If present and true, cards will be spawned next to each other in a\n-- spread moving to the right. globalPos will define the location of the first card, each\n-- after that will be moved a predefined distance\n-- spreadCols: Optional integer. If spread is true, specifies the maximum columns cards will be\n-- laid out in before starting a new row. If spread is true but spreadCols is not set, all\n-- cards will be in a single row (however long that may be)\n-- }\n-- See BondedBag.ttslua for an example\ndo\n local allCardsBagApi = require(\"playercards/AllCardsBagApi\")\n\n local SpawnBag = { }\n local internal = { }\n\n -- To assist debugging, will draw a box around the recall zone when it's set up\n local SHOW_RECALL_ZONE = false\n\n -- Distance to expand the recall zone around any added object.\n local RECALL_BUFFER_X = 0.9\n local RECALL_BUFFER_Z = 0.5\n\n -- In order to mimic the behavior of the previous memory buttons we use a temporary bag when\n -- recalling objects. This bag is tiny and transparent, and will be placed at the same location as\n -- this object. Once all placed cards are recalled bag to this bag, it will be destroyed\n local RECALL_BAG = {\n Name = \"Bag\",\n Transform = {\n scaleX = 0.01,\n scaleY = 0.01,\n scaleZ = 0.01,\n },\n ColorDiffuse = {\n r = 0,\n g = 0,\n b = 0,\n a = 0,\n },\n Locked = true,\n Grid = true,\n Snap = false,\n Tooltip = false\n }\n\n -- Tracks what has been placed by this \"bag\" so they can be recalled\n local placedSpecs = { }\n local placedObjectGuids = { }\n local recallZone = nil\n\n -- Loads a table of saved state, extracted during the parent object's onLoad\n SpawnBag.loadFromSave = function(saveTable)\n placedSpecs = saveTable.placed\n placedObjectGuids = saveTable.placedObjects\n recallZone = saveTable.recall\n end\n\n -- Generates a table of save state that can be included in the parent object's onSave\n SpawnBag.getStateForSave = function()\n return {\n placed = placedSpecs,\n placedObjects = placedObjectGuids,\n recall = recallZone,\n }\n end\n\n -- Places the given spawnSpec on the table. See comment at the start of the file for spawnSpec table data and examples\n SpawnBag.spawn = function(spawnSpec)\n -- Limit to one placement at a time\n if (placedSpecs[spawnSpec.name]) then\n return\n end\n if (spawnSpec == nil) then\n -- TODO: error here\n return\n end\n local cardsToSpawn = { }\n local cardList = spawnSpec.cards\n for _, cardId in ipairs(cardList) do\n local cardData = allCardsBagApi.getCardById(cardId)\n if (cardData ~= nil) then\n table.insert(cardsToSpawn, cardData)\n else\n -- TODO: error here\n end\n end\n if (spawnSpec.spread) then\n Spawner.spawnCardSpread(cardsToSpawn, spawnSpec.globalPos, spawnSpec.spreadCols or 9999, spawnSpec.rotation, false, internal.recordPlacedObject)\n else\n -- TTS decks come out in reverse order of the cards, reverse the list so the input order stays\n -- This only applies for decks; spreads are spawned by us in the order given\n if spawnSpec.rotation.z ~= 180 then\n cardsToSpawn = internal.reverseList(cardsToSpawn)\n end\n Spawner.spawnCards(cardsToSpawn, spawnSpec.globalPos, spawnSpec.rotation, false, internal.recordPlacedObject)\n end\n placedSpecs[spawnSpec.name] = true\n end\n\n -- Recalls all spawned objects to the bag, and clears the placedObjectGuids list\n ---@param fast boolean If true, cards will be deleted directly without faking the bag recall.\n SpawnBag.recall = function(fast)\n if fast then\n internal.deleteSpawned()\n else\n internal.recallSpawned()\n end\n\n -- We've recalled everything we can, some cards may have been moved out of the\n -- card area. Just reset at this point.\n placedSpecs = { }\n placedObjectGuids = { }\n recallZone = nil\n end\n\n -- Deleted all spawned cards.\n internal.deleteSpawned = function()\n for guid, _ in pairs(placedObjectGuids) do\n local obj = getObjectFromGUID(guid)\n if (obj ~= nil) then\n if (internal.isInRecallZone(obj)) then\n obj.destruct()\n end\n placedObjectGuids[guid] = nil\n end\n end\n end\n\n -- Recalls spawned cards with a fake bag that replicates the memory bag recall style.\n internal.recallSpawned = function()\n local trash = spawnObjectData({data = RECALL_BAG, position = self.getPosition()})\n for guid, _ in pairs(placedObjectGuids) do\n local obj = getObjectFromGUID(guid)\n if (obj ~= nil) then\n if (internal.isInRecallZone(obj)) then\n trash.putObject(obj)\n end\n placedObjectGuids[guid] = nil\n end\n end\n\n trash.destruct()\n end\n\n\n -- Callback for when an object has been spawned. Tracks the object for later recall and updates the\n -- recall zone.\n internal.recordPlacedObject = function(spawned)\n placedObjectGuids[spawned.getGUID()] = true\n internal.expandRecallZone(spawned)\n end\n\n -- Expands the current recall zone based on the position of the given object. The recall zone will\n -- be maintained as the bounding box of the extreme object positions, plus a small amount of buffer\n internal.expandRecallZone = function(spawnedCard)\n local pos = spawnedCard.getPosition()\n if (recallZone == nil) then\n -- First card out of the bag, initialize surrounding that\n recallZone = { }\n recallZone.upperLeft = { x = pos.x + RECALL_BUFFER_X, z = pos.z + RECALL_BUFFER_Z }\n recallZone.lowerRight = { x = pos.x - RECALL_BUFFER_X, z = pos.z - RECALL_BUFFER_Z }\n return\n else\n if (pos.x \u003e recallZone.upperLeft.x) then\n recallZone.upperLeft.x = pos.x + RECALL_BUFFER_X\n end\n if (pos.x \u003c recallZone.lowerRight.x) then\n recallZone.lowerRight.x = pos.x - RECALL_BUFFER_X\n end\n if (pos.z \u003e recallZone.upperLeft.z) then\n recallZone.upperLeft.z = pos.z + RECALL_BUFFER_Z\n end\n if (pos.z \u003c recallZone.lowerRight.z) then\n recallZone.lowerRight.z = pos.z - RECALL_BUFFER_Z\n end\n end\n if (SHOW_RECALL_ZONE) then\n local y = 1.5\n local thick = 0.05\n Global.setVectorLines({\n {\n points = { {recallZone.upperLeft.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.lowerRight.z} },\n color = {1,0,0},\n thickness = thick,\n rotation = {0,0,0}\n },\n {\n points = { {recallZone.upperLeft.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.lowerRight.z} },\n color = {1,0,0},\n thickness = thick,\n rotation = {0,0,0}\n },\n {\n points = { {recallZone.lowerRight.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.upperLeft.z} },\n color = {1,0,0},\n thickness = thick,\n rotation = {0,0,0}\n },\n {\n points = { {recallZone.lowerRight.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.upperLeft.z} },\n color = {1,0,0},\n thickness = thick,\n rotation = {0,0,0}\n }\n })\n end\n end\n\n -- Checks to see if the given object is in the current recall zone. If there isn't a recall zone,\n -- will return true so that everything can be easily cleaned up.\n internal.isInRecallZone = function(obj)\n if (recallZone == nil) then\n return true\n end\n local pos = obj.getPosition()\n return (pos.x \u003c recallZone.upperLeft.x and pos.x \u003e recallZone.lowerRight.x\n and pos.z \u003c recallZone.upperLeft.z and pos.z \u003e recallZone.lowerRight.z)\n end\n\n internal.reverseList = function(list)\n local reversed = { }\n for i = 1, #list do\n reversed[i] = list[#list - i + 1]\n end\n\n return reversed\n end\n\n return SpawnBag\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"playercards/AllCardsBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local AllCardsBagApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getAllCardsBag()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"AllCardsBag\")\n end\n\n -- Returns a specific card from the bag, based on ArkhamDB ID\n ---@param id table String ID of the card to retrieve\n ---@return table table\n -- If the indexes are still being constructed, an empty table is\n -- returned. Otherwise, a single table with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardById = function(id)\n return getAllCardsBag().call(\"getCardById\", {id = id})\n end\n\n -- Gets a random basic weakness from the bag. Once a given ID has been returned\n -- it will be removed from the list and cannot be selected again until a reload\n -- occurs or the indexes are rebuilt, which will refresh the list to include all\n -- weaknesses.\n ---@return string: ID of the selected weakness.\n AllCardsBagApi.getRandomWeaknessId = function()\n return getAllCardsBag().call(\"getRandomWeaknessId\")\n end\n\n AllCardsBagApi.isIndexReady = function()\n return getAllCardsBag().call(\"isIndexReady\")\n end\n\n -- Called by Hotfix bags when they load. If we are still loading indexes, then\n -- the all cards and hotfix bags are being loaded together, and we can ignore\n -- this call as the hotfix will be included in the initial indexing. If it is\n -- called once indexing is complete it means the hotfix bag has been added\n -- later, and we should rebuild the index to integrate the hotfix bag.\n AllCardsBagApi.rebuildIndexForHotfix = function()\n return getAllCardsBag().call(\"rebuildIndexForHotfix\")\n end\n\n -- Searches the bag for cards which match the given name and returns a list. Note that this is\n -- an O(n) search without index support. It may be slow.\n ---@param name string or string fragment to search for names\n ---@param exact boolean Whether the name match should be exact\n AllCardsBagApi.getCardsByName = function(name, exact)\n return getAllCardsBag().call(\"getCardsByName\", {name = name, exact = exact})\n end\n\n AllCardsBagApi.isBagPresent = function()\n return getAllCardsBag() and true\n end\n\n -- Returns a list of cards from the bag matching a class and level (0 or upgraded)\n ---@param class string class to retrieve (\"Guardian\", \"Seeker\", etc)\n ---@param upgraded boolean true for upgraded cards (Level 1-5), false for Level 0\n ---@return table: If the indexes are still being constructed, returns an empty table.\n -- Otherwise, a list of tables, each with the following fields\n -- cardData: TTS object data, suitable for spawning the card\n -- cardMetadata: Table of parsed metadata\n AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded)\n return getAllCardsBag().call(\"getCardsByClassAndLevel\", {class = class, upgraded = upgraded})\n end\n\n AllCardsBagApi.getCardsByCycle = function(cycle)\n return getAllCardsBag().call(\"getCardsByCycle\", cycle)\n end\n\n AllCardsBagApi.getUniqueWeaknesses = function()\n return getAllCardsBag().call(\"getUniqueWeaknesses\")\n end\n\n return AllCardsBagApi\nend\nend)\n__bundle_register(\"playercards/PlayerCardPanelData\", function(require, _LOADED, __bundle_register, __bundle_modules)\nBONDED_CARD_LIST = {\n\t\"05314\", -- Soothing Melody\n\t\"06277\", -- Wish Eater\n\t\"06019\", -- Bloodlust\n\t\"06022\", -- Pendant of the Queen\n\t\"05317\", -- Blood-rite\n\t\"06113\", -- Essence of the Dream\n\t\"06028\", -- Stars Are Right\n\t\"06025\", -- Guardian of the Crystallizer\n\t\"06283\", -- Unbound Beast\n\t\"06032\", -- Zeal\n\t\"06031\", -- Hope\n\t\"06033\", -- Augur\n\t\"06331\", -- Dream Parasite\n\t\"06015a\", -- Dream-Gate\n\t\"10006\",\t\t-- Aetheric Current (Yuggoth)\n\t\"10007\",\t\t-- Aetheric Current (Yoth)\n\t\"10036\",\t\t-- Blade of Yoth\n\t\"10039\",\t\t-- Evanescent Ascension\n\t\"10045\", -- Uncanny Growth\n\t\"10063\",\t\t-- Bianca\n\t\"10086\",\t\t-- Rot\n\t\"10087\",\t\t-- Rot\n\t\"10088\",\t\t-- Rot\n\t\"10089\",\t\t-- Rot\n\t\"10090\",\t\t-- Rot\n\t\"10106\",\t\t-- Keeper of the Key\n\t\"10107\",\t\t-- Servant of Brass\n\t\"10134\",\t\t-- Twilight Diadem\n}\n\nUPGRADE_SHEET_LIST = {\n\t\"09040-c\", -- Alchemical Distillation\n\t\"09023-c\", -- Custom Modifications\n\t\"09059-c\", -- Damning Testimony\n\t\"09041-c\", -- Emperical Hypothesis\n\t\"09060-c\", -- Friends in Low Places\n\t\"09101-c\", -- Grizzled\n\t\"09061-c\", -- Honed Instinct\n\t\"09021-c\", -- Hunter's Armor\n\t\"09119-c\", -- Hyperphysical Shotcaster\n\t\"09079-c\", -- Living Ink\n\t\"09100-c\", -- Makeshift Trap\n\t\"09099-c\", -- Pocket Multi Tool\n\t\"09081-c\", -- Power Word\n\t\"09081-t-c\", -- Power Word (Taboo)\n\t\"09022-c\", -- Runic Axe\n\t\"09022-t-c\", -- Runic Axe (Taboo)\n\t\"09080-c\", -- Summoned Servitor\n\t\"09042-c\", -- Raven's Quill\n}\n\nEVOLVED_WEAKNESSES = {\n\t\"04039\",\n\t\"04041\",\n\t\"04042\",\n\t\"53014\",\n\t\"53015\",\n}\n\n------------------ START INVESTIGATOR DATA DEFINITION ------------------\nINVESTIGATOR_GROUPS = {\n [\"Guardian\"] = {\n \"Roland Banks\",\n \t\"Zoey Samaras\",\n \t\"Mark Harrigan\",\n \t\"Leo Anderson\",\n \t\"Carolyn Fern\",\n \t\"Tommy Muldoon\",\n \t\"Nathaniel Cho\",\n \t\"Sister Mary\",\n \t\"Daniela Reyes\",\n \t\"Carson Sinclair\",\n\t\t\"Wilson Richards\"\n },\n [\"Seeker\"] = {\n \"Daisy Walker\",\n \t\"Rex Murphy\",\n \t\"Minh Thi Phan\",\n \t\"Ursula Downs\",\n \t\"Joe Diamond\",\n \t\"Mandy Thompson\",\n \t\"Harvey Walters\",\n \t\"Amanda Sharpe\",\n \t\"Norman Withers\",\n \t\"Vincent Lee\",\n\t\t\"Kate Winthrop\"\n },\n [\"Rogue\"] = {\n \t\"\\\"Skids\\\" O'Toole\",\n \t\"Jenny Barnes\",\n \t\"Sefina Rousseau\",\n \t\"Finn Edwards\",\n \t\"Preston Fairmont\",\n \t\"Tony Morgan\",\n \t\"Winifred Habbamock\",\n \t\"Trish Scarborough\",\n \t\"Monterey Jack\",\n \t\"Kymani Jones\",\n\t\t\"Alessandra Zorzi\"\n },\n [\"Mystic\"] = {\n \t\"Agnes Baker\",\n \t\"Jim Culver\",\n \t\"Akachi Onyele\",\n \t\"Father Mateo\",\n \t\"Diana Stanley\",\n \t\"Marie Lambeau\",\n \t\"Luke Robinson\",\n \t\"Jacqueline Fine\",\n \t\"Dexter Drake\",\n \t\"Lily Chen\",\n \t\"Amina Zidane\",\n \t\"Gloria Goldberg\",\n\t\t\"Kōhaku Narukami\"\n },\n [\"Survivor\"] = {\n \t\"Wendy Adams\",\n \t\"\\\"Ashcan\\\" Pete\",\n \t\"William Yorick\",\n \t\"Calvin Wright\",\n \t\"Rita Young\",\n \t\"Patrice Hathaway\",\n \t\"Stella Clark\",\n \t\"Silas Marsh\",\n \t\"Bob Jenkins\",\n \t\"Darrell Simmons\",\n\t\t\"Hank Samson\"\n },\n [\"Neutral\"] = {\n \t\"Lola Hayes\",\n \t\"Charlie Kane\",\n \t\"Subject 5U-21\"\n },\n [\"Core\"] = {\n \"Roland Banks\",\n \"Daisy Walker\",\n \"\\\"Skids\\\" O'Toole\",\n \"Agnes Baker\",\n \"Wendy Adams\"\n },\n [\"The Dunwich Legacy\"] = {\n \t\"Zoey Samaras\",\n \t\"Rex Murphy\",\n \t\"Jenny Barnes\",\n \t\"Jim Culver\",\n \t\"\\\"Ashcan\\\" Pete\"\n },\n [\"The Path to Carcosa\"] = {\n \t\"Mark Harrigan\",\n \t\"Minh Thi Phan\",\n \t\"Sefina Rousseau\",\n \t\"Akachi Onyele\",\n \t\"William Yorick\",\n \t\"Lola Hayes\"\n },\n [\"The Forgotten Age\"] = {\n \t\"Leo Anderson\",\n \t\"Ursula Downs\",\n \t\"Finn Edwards\",\n \t\"Father Mateo\",\n \t\"Calvin Wright\"\n },\n [\"The Circle Undone\"] = {\n \t\"Carolyn Fern\",\n \t\"Joe Diamond\",\n \t\"Preston Fairmont\",\n \t\"Diana Stanley\",\n \t\"Rita Young\",\n \t\"Marie Lambeau\"\n },\n [\"The Dream-Eaters\"] = {\n \t\"Tommy Muldoon\",\n \t\"Mandy Thompson\",\n \t\"Tony Morgan\",\n \t\"Luke Robinson\",\n \t\"Patrice Hathaway\"\n },\n [\"Investigator Packs\"] = {\n \t\"Nathaniel Cho\",\n \t\"Harvey Walters\",\n \t\"Winifred Habbamock\",\n \t\"Jacqueline Fine\",\n \t\"Stella Clark\",\n \t\"Gloria Goldberg\"\n },\n [\"The Innsmouth Conspiracy\"] = {\n \t\"Sister Mary\",\n \t\"Amanda Sharpe\",\n \t\"Trish Scarborough\",\n \t\"Dexter Drake\",\n \t\"Silas Marsh\"\n },\n [\"Edge of the Earth\"] = {\n \t\"Daniela Reyes\",\n \t\"Norman Withers\",\n \t\"Monterey Jack\",\n \t\"Lily Chen\",\n \t\"Bob Jenkins\"\n },\n [\"The Scarlet Keys\"] = {\n \t\"Carson Sinclair\",\n \t\"Vincent Lee\",\n \t\"Kymani Jones\",\n \t\"Amina Zidane\",\n \t\"Darrell Simmons\",\n \t\"Charlie Kane\"\n },\n\t[\"The Feast of Hemlock Vale\"] = {\n\t\t\"Wilson Richards\",\n\t\t\"Kate Winthrop\",\n\t\t\"Alessandra Zorzi\",\n\t\t\"Kōhaku Narukami\",\n\t\t\"Hank Samson\"\n\t}\n}\n\nINVESTIGATORS = {}\n-- Core Box\nINVESTIGATORS[\"Roland Banks\"] = {\n\tcards = { \"01001\", \"01001-p\", \"01001-pf\", \"01001-pb\" },\n\tminicards = { \"01001-m\" },\n\tsignatures = { \"01006\", \"01007\", \"90030\", \"90031\", \"90025\", \"90026\", \"90027\", \"90028\", \"90029\", \"98005\", \"98006\" },\n\tstarterDeck = \"2624931\"\n}\nINVESTIGATORS[\"Daisy Walker\"] = {\n\tcards = { \"01002\", \"01002-p\", \"01002-pf\", \"01002-pb\" },\n\tminicards = { \"01002-m\" },\n\tsignatures = { \"01008\", \"01009\", \"90002\", \"90003\" },\n\tstarterDeck = \"2624938\"\n}\nINVESTIGATORS[\"\\\"Skids\\\" O'Toole\"] = {\n\tcards = { \"01003\", \"01003-p\", \"01003-pf\", \"01003-pb\" },\n\tminicards = { \"01003-m\" },\n\tsignatures = { \"01010\", \"01011\", \"90009\", \"90010\" },\n\tstarterDeck = \"2624940\"\n}\nINVESTIGATORS[\"Agnes Baker\"] = {\n\tcards = { \"01004\", \"01004-p\", \"01004-pf\", \"01004-pb\" },\n\tminicards = { \"01004-m\" },\n\tsignatures = { \"01012\", \"01013\", \"90018\", \"90019\" },\n\tstarterDeck = \"2624944\"\n}\nINVESTIGATORS[\"Wendy Adams\"] = {\n\tcards = { \"01005\", \"01005-p\", \"01005-pf\", \"01005-pb\" },\n\tminicards = { \"01005-m\" },\n\tsignatures = { \"01014\", \"01015\", \"01515\", \"90039\", \"90040\", \"90038\" },\n\tstarterDeck = \"2624949\"\n}\n-- The Dunwich Legacy\nINVESTIGATORS[\"Zoey Samaras\"] = {\n\tcards = { \"02001\", \"02001-p\", \"02001-pf\", \"02001-pb\" },\n\tminicards = { \"02001-m\" },\n\tsignatures = { \"02006\", \"02007\", \"90060\", \"90061\" },\n\tstarterDeck = \"2624950\"\n}\nINVESTIGATORS[\"Rex Murphy\"] = {\n\tcards = { \"02002\", \"02002-t\", \"02002-p\", \"02002-pf\", \"02002-pb\" },\n\tminicards = { \"02002-m\" },\n\tsignatures = { \"02008\", \"02009\", \"90079\", \"90080\" },\n\tstarterDeck = \"2624958\"\n}\nINVESTIGATORS[\"Jenny Barnes\"] = {\n\tcards = { \"02003\" },\n\tminicards = { \"02003-m\" },\n\tsignatures = { \"02010\", \"02011\", \"98002\", \"98003\" },\n\tstarterDeck = \"2624961\"\n}\nINVESTIGATORS[\"Jim Culver\"] = {\n\tcards = { \"02004\", \"02004-p\", \"02004-pf\", \"02004-pb\" },\n\tminicards = { \"02004-m\" },\n\tsignatures = { \"02012\", \"02013\", \"90050\", \"90051\", \"90052\", \"90053\" },\n\tstarterDeck = \"2624965\"\n}\nINVESTIGATORS[\"\\\"Ashcan\\\" Pete\"] = {\n\tcards = { \"02005\", \"02005-p\", \"02005-pf\", \"02005-pb\" },\n\tminicards = { \"02005-m\" },\n\tsignatures = { \"02014\", \"02015\", \"90047\", \"90048\" },\n\tstarterDeck = \"2624969\"\n}\n-- The Path to Carcosa\nINVESTIGATORS[\"Mark Harrigan\"] = {\n\tcards = { \"03001\" },\n\tminicards = { \"03001-m\" },\n\tsignatures = { \"03007\", \"03008\", \"03009\" },\n\tstarterDeck = \"2624975\"\n}\nINVESTIGATORS[\"Minh Thi Phan\"] = {\n\tcards = { \"03002\" },\n\tminicards = { \"03002-m\" },\n\tsignatures = { \"03010\", \"03011\" },\n\tstarterDeck = \"2624979\"\n}\nINVESTIGATORS[\"Sefina Rousseau\"] = {\n\tcards = { \"03003\" },\n\tminicards = { \"03003-m\" },\n\tsignatures = { \"03012\", \"03012\", \"03012\", \"03013\" },\n\tstarterDeck = \"2624981\"\n}\nINVESTIGATORS[\"Akachi Onyele\"] = {\n\tcards = { \"03004\" },\n\tminicards = { \"03004-m\" },\n\tsignatures = { \"03014\", \"03015\" },\n\tstarterDeck = \"2624984\"\n}\nINVESTIGATORS[\"William Yorick\"] = {\n\tcards = { \"03005\" },\n\tminicards = { \"03005-m\" },\n\tsignatures = { \"03016\", \"03017\" },\n\tstarterDeck = \"2624988\"\n}\nINVESTIGATORS[\"Lola Hayes\"] = {\n\tcards = { \"03006\", \"03006-t\" },\n\tminicards = { \"03006-m\" },\n\tsignatures = { \"03018\", \"03018\", \"03019\", \"03019\", \"03019-t\", \"03019-t\" },\n\tstarterDeck = \"2624990\"\n}\n-- The Forgotten Age\nINVESTIGATORS[\"Leo Anderson\"] = {\n\tcards = { \"04001\" },\n\tminicards = { \"04001-m\" },\n\tsignatures = { \"04006\", \"04007\" },\n\tstarterDeck = \"2624994\"\n}\nINVESTIGATORS[\"Ursula Downs\"] = {\n\tcards = { \"04002\" },\n\tminicards = { \"04002-m\" },\n\tsignatures = { \"04008\", \"04009\" },\n\tstarterDeck = \"2625000\"\n}\nINVESTIGATORS[\"Finn Edwards\"] = {\n\tcards = { \"04003\" },\n\tminicards = { \"04003-m\" },\n\tsignatures = { \"04010\", \"04011\", \"04012\" },\n\tstarterDeck = \"2625003\"\n}\nINVESTIGATORS[\"Father Mateo\"] = {\n\tcards = { \"04004\" },\n\tminicards = { \"04004-m\" },\n\tsignatures = { \"04013\", \"04014\" },\n\tstarterDeck = \"2625005\"\n}\nINVESTIGATORS[\"Calvin Wright\"] = {\n\tcards = { \"04005\" },\n\tminicards = { \"04005-m\" },\n\tsignatures = { \"04015\", \"04016\" },\n\tstarterDeck = \"2625007\"\n}\n-- The Circle Undone\nINVESTIGATORS[\"Carolyn Fern\"] = {\n\tcards = { \"05001\" },\n\tminicards = { \"05001-m\" },\n\tsignatures = { \"05007\", \"05008\", \"98011\", \"98012\" },\n\tstarterDeck = \"2626342\"\n}\nINVESTIGATORS[\"Joe Diamond\"] = {\n\tcards = { \"05002\" },\n\tminicards = { \"05002-m\" },\n\tsignatures = { \"05009\", \"05010\" },\n\tstarterDeck = \"2626347\"\n}\nINVESTIGATORS[\"Preston Fairmont\"] = {\n\tcards = { \"05003\" },\n\tminicards = { \"05003-m\" },\n\tsignatures = { \"05011\", \"05012\" },\n\tstarterDeck = \"2626365\"\n}\nINVESTIGATORS[\"Diana Stanley\"] = {\n\tcards = { \"05004\" },\n\tminicards = { \"05004-m\" },\n\tsignatures = { \"05013\", \"05014\", \"05015\" },\n\tstarterDeck = \"2626385\"\n}\nINVESTIGATORS[\"Rita Young\"] = {\n\tcards = { \"05005\" },\n\tminicards = { \"05005-m\" },\n\tsignatures = { \"05016\", \"05017\" },\n\tstarterDeck = \"2626387\"\n}\nINVESTIGATORS[\"Marie Lambeau\"] = {\n\tcards = { \"05006\" },\n\tminicards = { \"05006-m\" },\n\tsignatures = { \"05018\", \"05019\" },\n\tstarterDeck = \"2626395\"\n}\n-- The Dream-Eaters\nINVESTIGATORS[\"Tommy Muldoon\"] = {\n\tcards = { \"06001\" },\n\tminicards = { \"06001-m\" },\n\tsignatures = { \"06006\", \"06007\" },\n\tstarterDeck = \"2626402\"\n}\nINVESTIGATORS[\"Mandy Thompson\"] = {\n\tcards = { \"06002\", \"06002-t\" },\n\tminicards = { \"06002-m\" },\n\tsignatures = { \"06008\", \"06008\", \"06008\", \"06009\" },\n\tstarterDeck = \"2626410\"\n}\nINVESTIGATORS[\"Tony Morgan\"] = {\n\tcards = { \"06003\" },\n\tminicards = { \"06003-m\" },\n\tsignatures = { \"06010\", \"06011\", \"06011\", \"06012\" },\n\tstarterDeck = \"2626446\"\n}\nINVESTIGATORS[\"Luke Robinson\"] = {\n\tcards = { \"06004\" },\n\tminicards = { \"06004-m\" },\n\tsignatures = { \"06013\", \"06014\", \"06015\" },\n\tstarterDeck = \"2626452\"\n}\nINVESTIGATORS[\"Patrice Hathaway\"] = {\n\tcards = { \"06005\" },\n\tminicards = { \"06005-m\" },\n\tsignatures = { \"06016\", \"06017\" },\n\tstarterDeck = \"2626461\"\n}\n-- Starter Decks\nINVESTIGATORS[\"Nathaniel Cho\"] = {\n\tcards = { \"60101\" },\n\tminicards = { \"60101-m\" },\n\tsignatures = { \"60102\", \"60103\" },\n\tstarterDeck = \"2643925\"\n}\nINVESTIGATORS[\"Harvey Walters\"] = {\n\tcards = { \"60201\" },\n\tminicards = { \"60201-m\" },\n\tsignatures = { \"60202\", \"60203\" },\n\tstarterDeck = \"2643928\"\n}\nINVESTIGATORS[\"Winifred Habbamock\"] = {\n\tcards = { \"60301\" },\n\tminicards = { \"60301-m\" },\n\tsignatures = { \"60302\", \"60303\" },\n\tstarterDeck = \"2643931\"\n}\nINVESTIGATORS[\"Jacqueline Fine\"] = {\n\tcards = { \"60401\" },\n\tminicards = { \"60401-m\" },\n\tsignatures = { \"60402\", \"60403\" },\n\tstarterDeck = \"2643932\"\n}\nINVESTIGATORS[\"Stella Clark\"] = {\n\tcards = { \"60501\" },\n\tminicards = { \"60501-m\" },\n\tsignatures = { \"60502\", \"60502\", \"60502\", \"60503\" },\n\tstarterDeck = \"2643934\"\n}\n-- The Innsmouth Conspiracy\nINVESTIGATORS[\"Sister Mary\"] = {\n\tcards = { \"07001\" },\n\tminicards = { \"07001-m\" },\n\tsignatures = { \"07006\", \"07007\" },\n\tstarterDeck = \"2626464\"\n}\nINVESTIGATORS[\"Amanda Sharpe\"] = {\n\tcards = { \"07002\" },\n\tminicards = { \"07002-m\" },\n\tsignatures = { \"07008\", \"07009\" },\n\tstarterDeck = \"2626469\"\n}\nINVESTIGATORS[\"Trish Scarborough\"] = {\n\tcards = { \"07003\", \"07003-t\" },\n\tminicards = { \"07003-m\" },\n\tsignatures = { \"07010\", \"07011\" },\n\tstarterDeck = \"2626479\"\n}\nINVESTIGATORS[\"Dexter Drake\"] = {\n\tcards = { \"07004\" },\n\tminicards = { \"07004-m\" },\n\tsignatures = { \"07012\", \"07013\", \"98017\", \"98018\" },\n\tstarterDeck = \"2626672\"\n}\nINVESTIGATORS[\"Silas Marsh\"] = {\n\tcards = { \"07005\" },\n\tminicards = { \"07005-m\" },\n\tsignatures = { \"07014\", \"07015\", \"07016\", \"98014\", \"98015\" },\n\tstarterDeck = \"2626685\"\n}\n-- Edge of the Earth\nINVESTIGATORS[\"Daniela Reyes\"] = {\n\tcards = { \"08001\" },\n\tminicards = { \"08001-m\" },\n\tsignatures = { \"08002\", \"08003\" },\n\tstarterDeck = \"2634588\"\n}\nINVESTIGATORS[\"Norman Withers\"] = {\n\tcards = { \"08004\" },\n\tminicards = { \"08004-m\" },\n\tsignatures = { \"08005\", \"08006\", \"98008\", \"98009\" },\n\tstarterDeck = \"2634603\"\n}\nINVESTIGATORS[\"Monterey Jack\"] = {\n\tcards = { \"08007\", \"08007-p\", \"08007-pf\", \"08007-pb\" },\n\tminicards = { \"08007-m\" },\n\tsignatures = { \"08008\", \"08009\", \"90063\", \"90064\" },\n\tstarterDeck = \"2634652\"\n}\nINVESTIGATORS[\"Lily Chen\"] = {\n\tcards = { \"08010\" },\n\tminicards = { \"08010-m\" },\n\tsignatures = { \"08011a\", \"08012a\", \"08013a\", \"08014a\", \"08015\", \"08015\", \"08015\", \"08015\" },\n\tstarterDeck = \"2634658\"\n}\nINVESTIGATORS[\"Bob Jenkins\"] = {\n\tcards = { \"08016\" },\n\tminicards = { \"08016-m\" },\n\tsignatures = { \"08017\", \"08018\" },\n\tstarterDeck = \"2634643\"\n}\n-- The Scarlet Keys\nINVESTIGATORS[\"Carson Sinclair\"] = {\n\tcards = { \"09001\" },\n\tminicards = { \"09001-m\" },\n\tsignatures = { \"09002\", \"09002\", \"09003\" },\n\tstarterDeck = \"2634667\"\n}\nINVESTIGATORS[\"Vincent Lee\"] = {\n\tcards = { \"09004\" },\n\tminicards = { \"09004-m\" },\n\tsignatures = { \"09005\", \"09006\", \"09006\", \"09006\", \"09006\", \"09007\" },\n\tstarterDeck = \"2634675\"\n}\nINVESTIGATORS[\"Kymani Jones\"] = {\n\tcards = { \"09008\" },\n\tminicards = { \"09008-m\" },\n\tsignatures = { \"09009\", \"09010\" },\n\tstarterDeck = \"2634701\"\n}\nINVESTIGATORS[\"Amina Zidane\"] = {\n\tcards = { \"09011\" },\n\tminicards = { \"09011-m\" },\n\tsignatures = { \"09012\", \"09013\", \"09014\" },\n\tstarterDeck = \"2634697\"\n}\nINVESTIGATORS[\"Darrell Simmons\"] = {\n\tcards = { \"09015\" },\n\tminicards = { \"09015-m\" },\n\tsignatures = { \"09016\", \"09017\" },\n\tstarterDeck = \"2634757\"\n}\nINVESTIGATORS[\"Charlie Kane\"] = {\n\tcards = { \"09018\" },\n\tminicards = { \"09018-m\" },\n\tsignatures = { \"09019\", \"09020\" },\n\tstarterDeck = \"2634706\"\n}\n-- The Feast of Hemlock Vale\nINVESTIGATORS[\"Wilson Richards\"] = {\n\tcards = { \"10001\" },\n\tminicards = { \"10001-m\" },\n\tsignatures = { \"10002\", \"10003\" },\n\tstarterDeck = \"2634667\" --carson deck as placeholder\n}\nINVESTIGATORS[\"Kate Winthrop\"] = {\n\tcards = { \"10004\" },\n\tminicards = { \"10004-m\" },\n\tsignatures = { \"10005\", \"10006\", \"10007\", \"10008\" },\n\tstarterDeck = \"2643928\" --harvey deck as placeholder\n}\nINVESTIGATORS[\"Alessandra Zorzi\"] = {\n\tcards = { \"10009\" },\n\tminicards = { \"10009-m\" },\n\tsignatures = { \"10010\", \"10010\", \"10010\", \"10011\" },\n\tstarterDeck = \"2643931\" --winifred deck as placeholder\n}\nINVESTIGATORS[\"Kōhaku Narukami\"] = {\n\tcards = { \"10012\" },\n\tminicards = { \"10012-m\" },\n\tsignatures = { \"10013\", \"10014\" },\n\tstarterDeck = \"2636199\" --gloria deck as placeholder\n}\nINVESTIGATORS[\"Hank Samson\"] = {\n\tcards = { \"10015\", \"10015-b1\", \"10015-b2\" },\n\tminicards = { \"10015-m\" },\n\tsignatures = { \"10017\", \"10018\"},\n\tstarterDeck = \"2643934\" --stella deck as placeholder\n}\n-- PnP content\nINVESTIGATORS[\"Subject 5U-21\"] = {\n\tcards = { \"89001\" },\n\tminicards = { \"89001-m\" },\n\tsignatures = { \"89002\", \"89003\", \"89003\", \"89003\", \"89004\", \"89004\", \"89004\", \"89005\" },\n\tstarterDeck = \"2624990\" -- Lola's deck id until Suzi is on ArkhamDB\n}\n-- Promo content\nINVESTIGATORS[\"Gloria Goldberg\"] = {\n\tcards = { \"98019\" },\n\tminicards = { \"98019-m\" },\n\tsignatures = { \"98020\", \"98021\" },\n\tstarterDeck = \"2636199\"\n}\n------------------ END INVESTIGATOR DATA DEFINITION ------------------\nend)\n__bundle_register(\"playercards/PlayerCardSpawner\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Amount to shift for the next card (zShift) or next row of cards (xShift)\n-- Note that the table rotation is weird, and the X axis is vertical while the\n-- Z axis is horizontal\nlocal SPREAD_Z_SHIFT = -2.3\nlocal SPREAD_X_SHIFT = -3.66\n\nSpawner = { }\n\n-- Spawns a list of cards at the given position/rotation. This will separate cards by size -\n-- investigator, standard, and mini, spawning them in that order with larger cards on bottom. If\n-- there are different types, the provided callback will be called once for each type as it spawns\n-- either a card or deck.\n---@param cardList table A list of Player Card data structures (data/metadata)\n---@param pos tts__Vector table where the cards should be spawned (global)\n---@param rot tts__Vector table for the orientation of the spawned cards (global)\n---@param sort boolean True if this list of cards should be sorted before spawning\n---@param callback? function Callback to be called after the card/deck spawns.\nSpawner.spawnCards = function(cardList, pos, rot, sort, callback)\n if (sort) then\n table.sort(cardList, Spawner.cardComparator)\n end\n\n local miniCards = { }\n local standardCards = { }\n local investigatorCards = { }\n\n for _, card in ipairs(cardList) do\n if (card.metadata.type == \"Investigator\") then\n table.insert(investigatorCards, card)\n elseif (card.metadata.type == \"Minicard\") then\n table.insert(miniCards, card)\n else\n table.insert(standardCards, card)\n end\n end\n -- Spawn each of the three types individually. Each Y position shift accounts for the thickness\n -- of the spawned deck\n local position = { x = pos.x, y = pos.y, z = pos.z }\n Spawner.spawn(investigatorCards, position, rot, callback)\n\n position.y = position.y + (#investigatorCards + #standardCards) * 0.07\n Spawner.spawn(standardCards, position, rot, callback)\n\n position.y = position.y + (#standardCards + #miniCards) * 0.07\n Spawner.spawn(miniCards, position, rot, callback)\nend\n\nSpawner.spawnCardSpread = function(cardList, startPos, maxCols, rot, sort, callback)\n if (sort) then\n table.sort(cardList, Spawner.cardComparator)\n end\n\n local position = { x = startPos.x, y = startPos.y, z = startPos.z }\n -- Special handle the first row if we have less than a full single row, but only if there's a\n -- reasonable max column count. Single-row spreads will send a large value for maxCols\n if maxCols \u003c 100 and #cardList \u003c maxCols then\n position.z = startPos.z + ((maxCols - #cardList) / 2 * SPREAD_Z_SHIFT)\n end\n local cardsInRow = 0\n local rows = 0\n for _, card in ipairs(cardList) do\n Spawner.spawn({ card }, position, rot, callback)\n position.z = position.z + SPREAD_Z_SHIFT\n cardsInRow = cardsInRow + 1\n if cardsInRow \u003e= maxCols then\n rows = rows + 1\n local cardsForRow = #cardList - rows * maxCols\n if cardsForRow \u003e maxCols then\n cardsForRow = maxCols\n end\n position.z = startPos.z + ((maxCols - cardsForRow) / 2 * SPREAD_Z_SHIFT)\n position.x = position.x + SPREAD_X_SHIFT\n cardsInRow = 0\n end\n end\nend\n\n-- Spawn a specific list of cards. This method is for internal use and should not be called\n-- directly, use spawnCards instead.\n---@param cardList table A list of Player Card data structures (data/metadata)\n---@param pos table Position where the cards should be spawned (global)\n---@param rot table Rotation for the orientation of the spawned cards (global)\n---@param callback? function callback to be called after the card/deck spawns.\nSpawner.spawn = function(cardList, pos, rot, callback)\n if #cardList == 0 then return end\n\n -- Spawn a single card directly\n if #cardList == 1 then\n -- handle sideways card\n if cardList[1].data.SidewaysCard then\n rot = { rot.x, rot.y - 90, rot.z }\n end\n spawnObjectData({\n data = cardList[1].data,\n position = pos,\n rotation = rot,\n callback_function = callback\n })\n return\n end\n\n -- For multiple cards, construct a deck and spawn that\n local deck = Spawner.buildDeckDataTemplate()\n\n -- Decks won't inherently scale to the cards in them. The card list being spawned should be all\n -- the same type/size by this point, so use the first card to set the size\n deck.Transform = {\n scaleX = cardList[1].data.Transform.scaleX,\n scaleY = 1,\n scaleZ = cardList[1].data.Transform.scaleZ\n }\n\n local sidewaysDeck = true\n for _, spawnCard in ipairs(cardList) do\n Spawner.addCardToDeck(deck, spawnCard.data)\n -- set sidewaysDeck to false if any card is not a sideways card\n sidewaysDeck = (sidewaysDeck and spawnCard.data.SidewaysCard)\n end\n\n -- set the alt view angle for sideways decks\n if sidewaysDeck then\n deck.AltLookAngle = { x = 0, y = 180, z = 90 }\n rot = { rot.x, rot.y - 90, rot.z }\n end\n\n spawnObjectData({\n data = deck,\n position = pos,\n rotation = rot,\n callback_function = callback\n })\nend\n\n-- Inserts a card into the given deck. This does three things:\n-- 1. Add the card's data to ContainedObjects\n-- 2. Add the card's ID (the TTS CardID, not the Arkham ID) to the deck's\n-- ID list. Note that the deck's ID list is \"DeckIDs\" even though it\n-- contains a list of card Ids\n-- 3. Extract the card's CustomDeck table and add it to the deck. The deck's\n-- \"CustomDeck\" field is a list of all CustomDecks used by cards within the\n-- deck, keyed by the DeckID and referencing the custom deck table\n---@param deck table TTS deck data structure to add to\n---@param cardData table Data for the card to be inserted\nSpawner.addCardToDeck = function(deck, cardData)\n for customDeckId, customDeckData in pairs(cardData.CustomDeck) do\n if (deck.CustomDeck[customDeckId] == nil) then\n -- CustomDeck not added to deck yet, add it\n deck.CustomDeck[customDeckId] = customDeckData\n elseif (deck.CustomDeck[customDeckId].FaceURL == customDeckData.FaceURL) then\n -- CustomDeck for this card matches the current one for the deck, do nothing\n else\n -- CustomDeck data conflict\n local newDeckId = nil\n for deckId, customDeck in pairs(deck.CustomDeck) do\n if (customDeckData.FaceURL == customDeck.FaceURL) then\n newDeckId = deckId\n end\n end\n if (newDeckId == nil) then\n -- No non-conflicting custom deck for this card, add a new one\n newDeckId = Spawner.findNextAvailableId(deck.CustomDeck, \"1000\")\n deck.CustomDeck[newDeckId] = customDeckData\n end\n -- Update the card with the new CustomDeck info\n cardData.CardID = newDeckId..string.sub(cardData.CardID, 5)\n cardData.CustomDeck[customDeckId] = nil\n cardData.CustomDeck[newDeckId] = customDeckData\n break\n end\n end\n table.insert(deck.ContainedObjects, cardData)\n table.insert(deck.DeckIDs, cardData.CardID)\nend\n\n-- Create an empty deck data table which can have cards added to it. This\n-- creates a new table on each call without using metatables or previous\n-- definitions because we can't be sure that TTS doesn't modify the structure\n---@return table deck Table containing the minimal TTS deck data structure\nSpawner.buildDeckDataTemplate = function()\n local deck = {}\n deck.Name = \"Deck\"\n\n -- Card data. DeckIDs and CustomDeck entries will be built from the cards\n deck.ContainedObjects = {}\n deck.DeckIDs = {}\n deck.CustomDeck = {}\n\n -- Transform is required, Position and Rotation will be overridden by the spawn call so can be omitted here\n deck.Transform = {\n scaleX = 1,\n scaleY = 1,\n scaleZ = 1,\n }\n\n return deck\nend\n\n-- Returns the first ID which does not exist in the given table, starting at startId and increasing\n---@param objectTable table keyed by strings which are numbers\n---@param startId string possible ID.\n---@return string id \u003e= startId\nSpawner.findNextAvailableId = function(objectTable, startId)\n local id = startId\n while (objectTable[id] ~= nil) do\n id = tostring(tonumber(id) + 1)\n end\n return id\nend\n\n-- Get the PBCN (Permanent/Bonded/Customizable/Normal) value from the given metadata.\n---@return number PBCN 1 for Permanent, 2 for Bonded or 4 for Normal. The actual values are\n-- irrelevant as they provide only grouping and the order between them doesn't matter.\nSpawner.getpbcn = function(metadata)\n if metadata.permanent then\n return 1\n elseif metadata.bonded_to ~= nil then\n return 2\n else -- Normal card\n return 3\n end\nend\n\n-- Comparison function used to sort the cards in a deck. Groups bonded or\n-- permanent cards first, then sorts within theose types by name/subname.\n-- Normal cards will sort in standard alphabetical order, while\n-- permanent/bonded/customizable will be in reverse alphabetical order.\n--\n-- Since cards spawn in the order provided by this comparator, with the first\n-- cards ending up at the bottom of a pile, this ordering will spawn in reverse\n-- alphabetical order. This presents the cards in order for non-face-down\n-- areas, and presents them in order when Searching the face-down deck.\nSpawner.cardComparator = function(card1, card2)\n local pbcn1 = Spawner.getpbcn(card1.metadata)\n local pbcn2 = Spawner.getpbcn(card2.metadata)\n if pbcn1 ~= pbcn2 then\n return pbcn1 \u003e pbcn2\n end\n if pbcn1 == 3 then\n if card1.data.Nickname ~= card2.data.Nickname then\n return card1.data.Nickname \u003c card2.data.Nickname\n end\n return card1.data.Description \u003c card2.data.Description\n else\n if card1.data.Nickname ~= card2.data.Nickname then\n return card1.data.Nickname \u003e card2.data.Nickname\n end\n return card1.data.Description \u003e card2.data.Description\n end\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/PlayerCardPanel\")\nend)\n__bundle_register(\"arkhamdb/ArkhamDb\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local allCardsBagApi = require(\"playercards/AllCardsBagApi\")\n local playAreaApi = require(\"core/PlayAreaApi\")\n\n local ArkhamDb = {}\n local internal = {}\n \n local tabooList = {}\n local configuration\n\n local RANDOM_WEAKNESS_ID = \"01000\"\n\n ---@class Request\n local Request = {}\n\n -- Sets up the ArkhamDb interface. Should be called from the parent object on load.\n ArkhamDb.initialize = function()\n configuration = internal.getConfiguration()\n Request.start({ configuration.api_uri, configuration.taboo }, function(status)\n local json = JSON.decode(internal.fixUtf16String(status.text))\n for _, taboo in pairs(json) do\n local cards = {}\n\n for _, card in pairs(JSON.decode(taboo.cards)) do\n cards[card.code] = true\n end\n\n tabooList[taboo.id] = {\n date = taboo.date_start,\n cards = cards\n }\n end\n return true, nil\n end)\n end\n\n -- Start the deck build process for the given player color and deck ID. This\n -- will retrieve the deck from ArkhamDB, and pass to a callback for processing.\n ---@param playerColor string Color name of the player mat to place this deck on (e.g. \"Red\").\n ---@param deckId string ArkhamDB deck id to be loaded\n ---@param isPrivate boolean Whether this deck is published or private on ArkhamDB\n ---@param loadNewest boolean Whether the newest version of this deck should be loaded\n ---@param loadInvestigators boolean Whether investigator cards should be loaded as part of this deck\n ---@param callback function Callback which will be sent the results of this load\n --- Parameters to the callback will be:\n --- slots table A map of card ID to count in the deck\n --- investigatorCode String. ID of the investigator in this deck\n --- customizations table The decoded table of customization upgrades in this deck\n --- playerColor String. Color this deck is being loaded for\n ---@return boolean\n ---@return string\n ArkhamDb.getDecklist = function(\n playerColor,\n deckId,\n isPrivate,\n loadNewest,\n loadInvestigators,\n callback)\n -- Get a simple card to see if the bag indexes are complete. If not, abort\n -- the deck load. The called method will handle player notification.\n local checkCard = allCardsBagApi.getCardById(\"01001\")\n if (checkCard ~= nil and checkCard.data == nil) then\n return false, \"Indexing not complete\"\n end\n\n local deckUri = {\n configuration.api_uri,\n isPrivate and configuration.private_deck or configuration.public_deck,\n deckId\n }\n\n local deck = Request.start(deckUri, function(status)\n if string.find(status.text, \"\u003c!DOCTYPE html\u003e\") then\n internal.maybePrint(\"Private deck ID \" .. deckId .. \" is not shared\", playerColor)\n return false, \"Private deck \" .. deckId .. \" is not shared\"\n end\n local json = JSON.decode(status.text)\n\n if not json then\n internal.maybePrint(\"Deck ID \" .. deckId .. \" not found\", playerColor)\n return false, \"Deck not found!\"\n end\n\n return true, json\n end)\n\n deck:with(internal.onDeckResult, playerColor, loadNewest, loadInvestigators, callback)\n end\n\n -- Logs that a card could not be loaded in the mod by printing it to the console in the given\n -- color of the player owning the deck. Attempts to look up the name on ArkhamDB for clarity,\n -- but prints the card ID if the name cannot be retrieved.\n ---@param cardId string ArkhamDB ID of the card that could not be found\n ---@param playerColor string Color of the player's deck that had the problem\n ArkhamDb.logCardNotFound = function(cardId, playerColor)\n local request = Request.start({\n configuration.api_uri,\n configuration.cards,\n cardId\n },\n function(result)\n local adbCardInfo = JSON.decode(internal.fixUtf16String(result.text))\n local cardName = adbCardInfo.real_name\n if (cardName ~= nil) then\n if (adbCardInfo.xp ~= nil and adbCardInfo.xp \u003e 0) then\n cardName = cardName .. \" (\" .. adbCardInfo.xp .. \")\"\n end\n internal.maybePrint(\"Card not found: \" .. cardName .. \", card ID \" .. cardId, playerColor)\n else\n internal.maybePrint(\"Card not found in ArkhamDB/Index, ID \" .. cardId, playerColor)\n end\n end)\n end\n\n -- Callback when the deck information is received from ArkhamDB. Parses the\n -- response then applies standard transformations to the deck such as adding\n -- random weaknesses and checking for taboos. Once the deck is processed,\n -- passes to loadCards to actually spawn the defined deck.\n ---@param deck table ArkhamImportDeck\n ---@param playerColor string Color name of the player mat to place this deck on (e.g. \"Red\")\n ---@param loadNewest boolean Whether the newest version of this deck should be loaded\n ---@param loadInvestigators boolean Whether investigator cards should be loaded as part of this deck\n ---@param callback function Callback which will be sent the results of this load.\n --- Parameters to the callback will be:\n --- slots table A map of card ID to count in the deck\n --- investigatorCode String. ID of the investigator in this deck\n --- bondedList A table of cardID keys to meaningless values. Card IDs in this list were\n --- added from a parent bonded card.\n --- customizations table The decoded table of customization upgrades in this deck\n --- playerColor String. Color this deck is being loaded for\n internal.onDeckResult = function(deck, playerColor, loadNewest, loadInvestigators, callback)\n -- Load the next deck in the upgrade path if the option is enabled\n if (loadNewest and deck.next_deck ~= nil and deck.next_deck ~= \"\") then\n buildDeck(playerColor, deck.next_deck)\n return\n end\n\n internal.maybePrint(table.concat({ \"Found decklist: \", deck.name }), playerColor)\n\n -- Initialize deck slot table and perform common transformations. The order of these should not\n -- be changed, as later steps may act on cards added in each. For example, a random weakness or\n -- investigator may have bonded cards or taboo entries, and should be present\n local slots = deck.slots\n internal.maybeDrawRandomWeakness(slots, playerColor)\n\n -- handles alternative investigators (parallel, promo or revised art)\n local loadAltInvestigator = \"normal\"\n if loadInvestigators then\n loadAltInvestigator = internal.addInvestigatorCards(deck, slots)\n end\n\n internal.maybeModifyDeckFromDescription(slots, deck.description_md, playerColor)\n internal.maybeAddSummonedServitor(slots)\n internal.maybeAddOnTheMend(slots, playerColor)\n internal.maybeAddRealityAcidReference(slots)\n local bondList = internal.extractBondedCards(slots)\n internal.checkTaboos(deck.taboo_id, slots, playerColor)\n internal.maybeAddUpgradeSheets(slots)\n\n -- get upgrades for customizable cards\n local customizations = {}\n if deck.meta then\n customizations = JSON.decode(deck.meta)\n end\n\n callback(slots, deck.investigator_code, bondList, customizations, playerColor, loadAltInvestigator)\n end\n\n -- Checks to see if the slot list includes the random weakness ID. If it does,\n -- removes it from the deck and replaces it with the ID of a random basic weakness provided by the\n -- all cards bag\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n --- of those cards which will be spawned\n ---@param playerColor string Color of the player this deck is being loaded for. Used for broadcast\n --- if a weakness is added.\n internal.maybeDrawRandomWeakness = function(slots, playerColor)\n local randomWeaknessAmount = slots[RANDOM_WEAKNESS_ID] or 0\n slots[RANDOM_WEAKNESS_ID] = nil\n\n if randomWeaknessAmount ~= 0 then\n for i=1, randomWeaknessAmount do\n local weaknessId = allCardsBagApi.getRandomWeaknessId()\n slots[weaknessId] = (slots[weaknessId] or 0) + 1\n end\n internal.maybePrint(\"Added \" .. randomWeaknessAmount .. \" random basic weakness(es) to deck\", playerColor)\n end\n end\n\n -- Adds both the investigator (XXXXX) and minicard (XXXXX-m) slots with one copy each\n ---@param deck table The processed ArkhamDB deck response\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the\n --- number of those cards which will be spawned\n ---@return string: Contains the name of the art that should be loaded (\"normal\", \"promo\" or \"revised\")\n internal.addInvestigatorCards = function(deck, slots)\n local investigatorId = deck.investigator_code\n slots[investigatorId .. \"-m\"] = 1\n local deckMeta = JSON.decode(deck.meta)\n\n -- handling alternative investigator art and parallel investigators\n local loadAltInvestigator = \"normal\"\n if deckMeta ~= nil then\n local altFrontId = tonumber(deckMeta.alternate_front) or 0\n local altBackId = tonumber(deckMeta.alternate_back) or 0\n local altArt = { front = \"normal\", back = \"normal\" }\n\n -- translating front ID\n if altFrontId \u003e 90000 and altFrontId \u003c 90100 then\n altArt.front = \"parallel\"\n elseif altFrontId \u003e 01500 and altFrontId \u003c 01506 then\n altArt.front = \"revised\"\n elseif altFrontId \u003e 98000 then\n altArt.front = \"promo\"\n end\n\n -- translating back ID\n if altBackId \u003e 90000 and altBackId \u003c 90100 then\n altArt.back = \"parallel\"\n elseif altBackId \u003e 01500 and altBackId \u003c 01506 then\n altArt.back = \"revised\"\n elseif altBackId \u003e 98000 then\n altArt.back = \"promo\"\n end\n\n -- updating investigatorID based on alt investigator selection\n -- precedence: parallel \u003e promo \u003e revised\n if altArt.front == \"parallel\" then\n if altArt.back == \"parallel\" then\n investigatorId = investigatorId .. \"-p\"\n else\n investigatorId = investigatorId .. \"-pf\"\n end\n elseif altArt.back == \"parallel\" then\n investigatorId = investigatorId .. \"-pb\"\n elseif altArt.front == \"promo\" or altArt.back == \"promo\" then\n loadAltInvestigator = \"promo\"\n elseif altArt.front == \"revised\" or altArt.back == \"revised\" then\n loadAltInvestigator = \"revised\"\n end\n end\n slots[investigatorId] = 1\n deck.investigator_code = investigatorId\n return loadAltInvestigator\n end\n\n -- Process the card list looking for the customizable cards, and add their upgrade sheets if needed\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n internal.maybeAddUpgradeSheets = function(slots)\n for cardId, _ in pairs(slots) do\n -- upgrade sheets for customizable cards\n local upgradesheet = allCardsBagApi.getCardById(cardId .. \"-c\")\n if upgradesheet ~= nil then\n slots[cardId .. \"-c\"] = 1\n end\n end\n end\n\n -- Process the card list looking for the Summoned Servitor, and add its minicard to the list if\n -- needed\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n internal.maybeAddSummonedServitor = function(slots)\n if slots[\"09080\"] ~= nil then\n slots[\"09080-m\"] = 1\n end\n end\n\n -- On the Mend should have 1-per-investigator copies set aside, but ArkhamDB always sends 1. Update\n -- the count based on the investigator count\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n ---@param playerColor string Color of the player this deck is being loaded for. Used for broadcast if an error occurs\n internal.maybeAddOnTheMend = function(slots, playerColor)\n if slots[\"09006\"] ~= nil then\n local investigatorCount = playAreaApi.getInvestigatorCount()\n if investigatorCount ~= nil then\n slots[\"09006\"] = investigatorCount\n else\n internal.maybePrint(\"Something went wrong with the load, adding 4 copies of On the Mend\", playerColor)\n slots[\"09006\"] = 4\n end\n end\n end\n\n -- Process the card list looking for Reality Acid and adds the reference sheet when needed\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n -- of those cards which will be spawned\n internal.maybeAddRealityAcidReference = function(slots)\n if slots[\"89004\"] ~= nil then\n slots[\"89005\"] = 1\n end\n end\n\n -- Processes the deck description from ArkhamDB and modifies the slot list accordingly\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number\n ---@param description string The deck desription from ArkhamDB\n internal.maybeModifyDeckFromDescription = function(slots, description, playerColor)\n -- check for import instructions\n local pos = string.find(description, \"++SCED import instructions++\")\n if not pos then return end\n\n -- remove everything before instructions\n local tempStr = string.sub(description, pos)\n\n -- parse each line in instructions\n for line in tempStr:gmatch(\"([^\\n]+)\") do\n -- remove dashes at the start\n line = line:gsub(\"%- \", \"\")\n\n -- remove spaces\n line = line:gsub(\"%s\", \"\")\n\n -- remove balanced brackets\n line = line:gsub(\"%b()\", \"\")\n line = line:gsub(\"%b[]\", \"\")\n\n -- get instructor\n local instructor = \"\"\n for word in line:gmatch(\"%a+:\") do\n instructor = word\n break\n end\n\n -- go to the next line if no valid instructor found\n if instructor ~= \"add:\" and instructor ~= \"remove:\" then\n goto nextLine\n end\n\n -- remove instructor from line\n line = line:gsub(instructor, \"\")\n\n -- evaluate instructions\n for str in line:gmatch(\"([^,]+)\") do\n if instructor == \"add:\" then\n slots[str] = (slots[str] or 0) + 1\n elseif instructor == \"remove:\" then\n if slots[str] == nil then\n internal.maybePrint(\"Tried to remove card ID \" .. str .. \", but didn't find card in deck.\", playerColor)\n else\n slots[str] = math.max(slots[str] - 1, 0)\n\n -- fully remove cards that have a quantity of 0\n if slots[str] == 0 then\n slots[str] = nil\n\n -- also remove related minicard\n slots[str .. \"-m\"] = nil\n end\n end\n end\n end\n\n -- jump mark at the end of the loop\n ::nextLine::\n end\n end\n\n -- Process the slot list and looks for any cards which are bonded to those in the deck. Adds those cards to the slot list.\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned\n internal.extractBondedCards = function(slots)\n -- Create a list of bonded cards first so we don't modify slots while iterating\n local bondedCards = { }\n local bondedList = { }\n for cardId, cardCount in pairs(slots) do\n local card = allCardsBagApi.getCardById(cardId)\n if card ~= nil and card.metadata.bonded ~= nil then\n for _, bond in ipairs(card.metadata.bonded) do\n -- 'unlimited' upper limit for cards without this data\n local maxCount = bond.maxCount or 99\n\n -- add a bonded card for each copy of the parent card (until the max value is reached)\n bondedCards[bond.id] = math.min(bond.count * cardCount, maxCount)\n\n -- We need to know which cards are bonded to determine their position, remember them\n bondedList[bond.id] = true\n\n -- Also adding taboo versions of bonded cards to the list\n bondedList[bond.id .. \"-t\"] = true\n end\n end\n end\n\n -- Add any bonded cards to the main slots list\n for bondedId, bondedCount in pairs(bondedCards) do\n slots[bondedId] = bondedCount\n end\n\n return bondedList\n end\n\n -- Check the deck for cards on its taboo list. If they're found, replace the entry in the slot with the Taboo id (i.e. \"XXXX\" becomes \"XXXX-t\")\n ---@param tabooId string The deck's taboo ID, taken from the deck response taboo_id field. May be nil, indicating that no taboo list should be used\n ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned\n internal.checkTaboos = function(tabooId, slots, playerColor)\n if tabooId then\n for cardId, _ in pairs(tabooList[tabooId].cards) do\n if slots[cardId] ~= nil then\n -- Make sure there's a taboo version of the card before we replace it\n -- SCED only maintains the most recent taboo cards. If a deck is using\n -- an older taboo list it's possible the card isn't a taboo any more\n local tabooCard = allCardsBagApi.getCardById(cardId .. \"-t\")\n if tabooCard == nil then\n local basicCard = allCardsBagApi.getCardById(cardId)\n internal.maybePrint(\"Taboo version for \" .. basicCard.data.Nickname .. \" is not available. Using standard version\", playerColor)\n else\n slots[cardId .. \"-t\"] = slots[cardId]\n slots[cardId] = nil\n end\n end\n end\n end\n end\n\n internal.maybePrint = function(message, playerColor)\n if playerColor ~= \"None\" then\n printToAll(message, playerColor)\n end\n end\n\n -- Gets the ArkhamDB config info from the configuration object.\n ---@return table: configuration data\n internal.getConfiguration = function()\n local configuration = getObjectsWithTag(\"import_configuration_provider\")[1].getTable(\"configuration\")\n printPriority = configuration.priority\n return configuration\n end\n\n internal.fixUtf16String = function(str)\n return str:gsub(\"\\\\u(%w%w%w%w)\", function(match)\n return string.char(tonumber(match, 16))\n end)\n end\n\n Request = {\n is_done = false,\n is_successful = false\n }\n\n -- Creates a new instance of a Request. Should not be directly called. Instead use Request.start() and Request.deferred().\n ---@param uri table\n ---@param configure fun(request, status)\n ---@return Request\n function Request:new(uri, configure)\n local this = {}\n\n setmetatable(this, self)\n self.__index = self\n\n if type(uri) == \"table\" then\n uri = table.concat(uri, \"/\")\n end\n\n this.uri = uri\n WebRequest.get(uri, function(status) configure(this, status) end)\n\n return this\n end\n\n -- Creates a new request. on_success should set the request's is_done, is_successful, and content variables.\n -- Deferred should be used when you don't want to set is_done immediately (such as if you want to wait for another request to finish)\n ---@param uri table\n ---@param on_success fun(request, status, vararg)\n ---@param on_error fun(status)|nil\n ---@return Request\n function Request.deferred(uri, on_success, on_error, ...)\n local parameters = table.pack(...)\n return Request:new(uri, function(request, status)\n if (status.is_done) then\n if (status.is_error) then\n request.error_message = on_error and on_error(status, table.unpack(parameters)) or status.error\n request.is_successful = false\n request.is_done = true\n else\n on_success(request, status)\n end\n end\n end)\n end\n\n -- Creates a new request. on_success should return whether the resultant data is as expected, and the processed content of the request.\n ---@param uri table\n ---@param on_success fun(status, vararg): boolean, any\n ---@param on_error nil|fun(status, vararg): string\n ---@vararg any\n ---@return Request\n function Request.start(uri, on_success, on_error, ...)\n local parameters = table.pack(...)\n return Request.deferred(uri, function(request, status)\n local result, message = on_success(status, table.unpack(parameters))\n if not result then request.error_message = message else request.content = message end\n request.is_successful = result\n request.is_done = true\n end, on_error, table.unpack(parameters))\n end\n\n ---@param requests Request[]\n ---@param on_success fun(content: any, vararg: any)\n ---@param on_error fun(requests: Request, vararg: any)|nil\n ---@vararg any\n function Request.with_all(requests, on_success, on_error, ...)\n local parameters = table.pack(...)\n\n Wait.condition(function()\n local results = {}\n local errors = {}\n\n for _, request in ipairs(requests) do\n if request.is_successful then\n table.insert(results, request.content)\n else\n table.insert(errors, request)\n end\n end\n\n if (#errors \u003c= 0) then\n on_success(results, table.unpack(parameters))\n elseif on_error == nil then\n for _, request in ipairs(errors) do\n internal.maybePrint(table.concat({ \"[ERROR]\", request.uri, \":\", request.error_message }))\n end\n else\n on_error(requests, table.unpack(parameters))\n end\n end, function()\n for _, request in ipairs(requests) do\n if not request.is_done then return false end\n end\n return true\n end)\n end\n\n function Request:with(callback, ...)\n local arguments = table.pack(...)\n Wait.condition(function()\n if self.is_successful then\n callback(self.content, table.unpack(arguments))\n end\n end, function() return self.is_done\n end)\n end\n\n return ArkhamDb\nend\nend)\n__bundle_register(\"playercards/SpawnBag\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"playercards/PlayerCardSpawner\")\n\n-- Allows spawning of defined lists of cards which will be created from the template in the All\n-- Player Cards bag. SpawnBag.spawn will create objects based on a table definition, while\n-- SpawnBag.recall will clean them all up. Recall will be limited to a small area around the\n-- spawned objects. Objects moved out of this area will not be cleaned up.\n--\n-- SpawnSpec: Spawning requires a spawn specification with the following structure:\n-- {\n-- name: Name of this spawn content, used for internal tracking. Multiple specs can be spawned,\n-- but each requires a separate name\n-- cards: A list of card IDs to be spawned\n-- globalPos: Where the spawned objects should be placed, in global coordinates. This should be\n-- a valid Vector with x, y, and z defined, e.g. { x = 5, y = 1, z = 15 }\n-- rotation: Rotation for the spawned objects. X=180 should be used for face down items. As with\n-- globalPos, this should be a valid Vector with x, y, and z defined\n-- spread: Optional Boolean. If present and true, cards will be spawned next to each other in a\n-- spread moving to the right. globalPos will define the location of the first card, each\n-- after that will be moved a predefined distance\n-- spreadCols: Optional integer. If spread is true, specifies the maximum columns cards will be\n-- laid out in before starting a new row. If spread is true but spreadCols is not set, all\n-- cards will be in a single row (however long that may be)\n-- }\n-- See BondedBag.ttslua for an example\ndo\n local allCardsBagApi = require(\"playercards/AllCardsBagApi\")\n\n local SpawnBag = { }\n local internal = { }\n\n -- To assist debugging, will draw a box around the recall zone when it's set up\n local SHOW_RECALL_ZONE = false\n\n -- Distance to expand the recall zone around any added object.\n local RECALL_BUFFER_X = 0.9\n local RECALL_BUFFER_Z = 0.5\n\n -- In order to mimic the behavior of the previous memory buttons we use a temporary bag when\n -- recalling objects. This bag is tiny and transparent, and will be placed at the same location as\n -- this object. Once all placed cards are recalled bag to this bag, it will be destroyed\n local RECALL_BAG = {\n Name = \"Bag\",\n Transform = {\n scaleX = 0.01,\n scaleY = 0.01,\n scaleZ = 0.01,\n },\n ColorDiffuse = {\n r = 0,\n g = 0,\n b = 0,\n a = 0,\n },\n Locked = true,\n Grid = true,\n Snap = false,\n Tooltip = false\n }\n\n -- Tracks what has been placed by this \"bag\" so they can be recalled\n local placedSpecs = { }\n local placedObjectGuids = { }\n local recallZone = nil\n\n -- Loads a table of saved state, extracted during the parent object's onLoad\n SpawnBag.loadFromSave = function(saveTable)\n placedSpecs = saveTable.placed\n placedObjectGuids = saveTable.placedObjects\n recallZone = saveTable.recall\n end\n\n -- Generates a table of save state that can be included in the parent object's onSave\n SpawnBag.getStateForSave = function()\n return {\n placed = placedSpecs,\n placedObjects = placedObjectGuids,\n recall = recallZone,\n }\n end\n\n -- Places the given spawnSpec on the table. See comment at the start of the file for spawnSpec table data and examples\n SpawnBag.spawn = function(spawnSpec)\n -- Limit to one placement at a time\n if (placedSpecs[spawnSpec.name]) then\n return\n end\n if (spawnSpec == nil) then\n -- TODO: error here\n return\n end\n local cardsToSpawn = { }\n local cardList = spawnSpec.cards\n for _, cardId in ipairs(cardList) do\n local cardData = allCardsBagApi.getCardById(cardId)\n if (cardData ~= nil) then\n table.insert(cardsToSpawn, cardData)\n else\n -- TODO: error here\n end\n end\n if (spawnSpec.spread) then\n Spawner.spawnCardSpread(cardsToSpawn, spawnSpec.globalPos, spawnSpec.spreadCols or 9999, spawnSpec.rotation, false, internal.recordPlacedObject)\n else\n -- TTS decks come out in reverse order of the cards, reverse the list so the input order stays\n -- This only applies for decks; spreads are spawned by us in the order given\n if spawnSpec.rotation.z ~= 180 then\n cardsToSpawn = internal.reverseList(cardsToSpawn)\n end\n Spawner.spawnCards(cardsToSpawn, spawnSpec.globalPos, spawnSpec.rotation, false, internal.recordPlacedObject)\n end\n placedSpecs[spawnSpec.name] = true\n end\n\n -- Recalls all spawned objects to the bag, and clears the placedObjectGuids list\n ---@param fast boolean If true, cards will be deleted directly without faking the bag recall.\n SpawnBag.recall = function(fast)\n if fast then\n internal.deleteSpawned()\n else\n internal.recallSpawned()\n end\n\n -- We've recalled everything we can, some cards may have been moved out of the\n -- card area. Just reset at this point.\n placedSpecs = { }\n placedObjectGuids = { }\n recallZone = nil\n end\n\n -- Deleted all spawned cards.\n internal.deleteSpawned = function()\n for guid, _ in pairs(placedObjectGuids) do\n local obj = getObjectFromGUID(guid)\n if (obj ~= nil) then\n if (internal.isInRecallZone(obj)) then\n obj.destruct()\n end\n placedObjectGuids[guid] = nil\n end\n end\n end\n\n -- Recalls spawned cards with a fake bag that replicates the memory bag recall style.\n internal.recallSpawned = function()\n local trash = spawnObjectData({data = RECALL_BAG, position = self.getPosition()})\n for guid, _ in pairs(placedObjectGuids) do\n local obj = getObjectFromGUID(guid)\n if (obj ~= nil) then\n if (internal.isInRecallZone(obj)) then\n trash.putObject(obj)\n end\n placedObjectGuids[guid] = nil\n end\n end\n\n trash.destruct()\n end\n\n\n -- Callback for when an object has been spawned. Tracks the object for later recall and updates the\n -- recall zone.\n internal.recordPlacedObject = function(spawned)\n placedObjectGuids[spawned.getGUID()] = true\n internal.expandRecallZone(spawned)\n end\n\n -- Expands the current recall zone based on the position of the given object. The recall zone will\n -- be maintained as the bounding box of the extreme object positions, plus a small amount of buffer\n internal.expandRecallZone = function(spawnedCard)\n local pos = spawnedCard.getPosition()\n if (recallZone == nil) then\n -- First card out of the bag, initialize surrounding that\n recallZone = { }\n recallZone.upperLeft = { x = pos.x + RECALL_BUFFER_X, z = pos.z + RECALL_BUFFER_Z }\n recallZone.lowerRight = { x = pos.x - RECALL_BUFFER_X, z = pos.z - RECALL_BUFFER_Z }\n return\n else\n if (pos.x \u003e recallZone.upperLeft.x) then\n recallZone.upperLeft.x = pos.x + RECALL_BUFFER_X\n end\n if (pos.x \u003c recallZone.lowerRight.x) then\n recallZone.lowerRight.x = pos.x - RECALL_BUFFER_X\n end\n if (pos.z \u003e recallZone.upperLeft.z) then\n recallZone.upperLeft.z = pos.z + RECALL_BUFFER_Z\n end\n if (pos.z \u003c recallZone.lowerRight.z) then\n recallZone.lowerRight.z = pos.z - RECALL_BUFFER_Z\n end\n end\n if (SHOW_RECALL_ZONE) then\n local y = 1.5\n local thick = 0.05\n Global.setVectorLines({\n {\n points = { {recallZone.upperLeft.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.lowerRight.z} },\n color = {1,0,0},\n thickness = thick,\n rotation = {0,0,0}\n },\n {\n points = { {recallZone.upperLeft.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.lowerRight.z} },\n color = {1,0,0},\n thickness = thick,\n rotation = {0,0,0}\n },\n {\n points = { {recallZone.lowerRight.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.upperLeft.z} },\n color = {1,0,0},\n thickness = thick,\n rotation = {0,0,0}\n },\n {\n points = { {recallZone.lowerRight.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.upperLeft.z} },\n color = {1,0,0},\n thickness = thick,\n rotation = {0,0,0}\n }\n })\n end\n end\n\n -- Checks to see if the given object is in the current recall zone. If there isn't a recall zone,\n -- will return true so that everything can be easily cleaned up.\n internal.isInRecallZone = function(obj)\n if (recallZone == nil) then\n return true\n end\n local pos = obj.getPosition()\n return (pos.x \u003c recallZone.upperLeft.x and pos.x \u003e recallZone.lowerRight.x\n and pos.z \u003c recallZone.upperLeft.z and pos.z \u003e recallZone.lowerRight.z)\n end\n\n internal.reverseList = function(list)\n local reversed = { }\n for i = 1, #list do\n reversed[i] = list[#list - i + 1]\n end\n\n return reversed\n end\n\n return SpawnBag\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playercards/PlayerCardPanel\", function(require, _LOADED, __bundle_register, __bundle_modules)\n---@diagnostic disable: param-type-mismatch\nrequire(\"playercards/PlayerCardPanelData\")\n\nlocal allCardsBagApi = require(\"playercards/AllCardsBagApi\")\nlocal arkhamDb = require(\"arkhamdb/ArkhamDb\")\nlocal spawnBag = require(\"playercards/SpawnBag\")\n\n-- Size and position information for the three rows of class buttons\nlocal CIRCLE_BUTTON_SIZE = 250\nlocal CLASS_BUTTONS_X_OFFSET = 0.1325\nlocal INVESTIGATOR_ROW_START = Vector(0.125, 0.1, -0.447)\nlocal LEVEL_ZERO_ROW_START = Vector(0.125, 0.1, -0.007)\nlocal UPGRADED_ROW_START = Vector(0.125, 0.1, 0.333)\n\n-- Size and position information for the two blocks of other buttons\nlocal MISC_BUTTONS_X_OFFSET = 0.155\nlocal WEAKNESS_ROW_START = Vector(0.157, 0.1, 0.666)\nlocal OTHER_ROW_START = Vector(0.605, 0.1, 0.666)\n\n-- Size and position information for the Cycle (box) buttons\nlocal CYCLE_BUTTON_SIZE = 468\nlocal CYCLE_BUTTON_START = Vector(-0.716, 0.1, -0.39)\nlocal CYCLE_COLUMN_COUNT = 3\nlocal CYCLE_BUTTONS_X_OFFSET = 0.267\nlocal CYCLE_BUTTONS_Z_OFFSET = 0.2665\n\nlocal STARTER_DECK_MODE_SELECTED_COLOR = { 0.2, 0.2, 0.2, 0.8 }\nlocal TRANSPARENT = { 0, 0, 0, 0 }\nlocal STARTER_DECK_MODE_STARTERS = \"starters\"\nlocal STARTER_DECK_MODE_CARDS_ONLY = \"cards\"\n\nlocal FACE_UP_ROTATION = { x = 0, y = 270, z = 0}\nlocal FACE_DOWN_ROTATION = { x = 0, y = 270, z = 180}\n\n-- ---------- IMPORTANT ----------\n-- Coordinates defined below are in global dimensions relative to the panel - DO NOT USE THESE\n-- DIRECTLY. Call scalePositions() before use, and reference the variables below\n\n-- Layout width for a single card, in global coordinate space\nlocal CARD_WIDTH = 2.3\n\n-- Coordinates to begin laying out cards. These vary based on the cards that are being placed by\n-- considering the width of the cards, number of cards, and desired spread intervals.\n-- IMPORTANT! Because of the mix of global card sizes and relative-to-scale positions, the X and Y\n-- coordinates on these provide global disances while the Z is local.\nlocal START_POSITIONS = {\n classCards = Vector(CARD_WIDTH * 9.5, 2, 1.4),\n investigator = Vector(6 * 2.5, 2, 1.3),\n cycle = Vector(CARD_WIDTH * 9.5, 2, 2.4),\n other = Vector(CARD_WIDTH * 9.5, 2, 1.4),\n randomWeakness = Vector(0, 2, 1.4),\n -- Because the card spread is handled by the SpawnBag, we don't know (programatically) where this\n -- should be placed. If more customizable cards are added it will need to be moved.\n summonedServitor = Vector(CARD_WIDTH * -7.5, 2, 1.7)\n}\n\n-- Shifts to move rows of cards, and groups of rows, as different groupings are laid out\nlocal CARD_ROW_OFFSET = 3.7\nlocal CARD_GROUP_OFFSET = 2\n\n-- Position offsets for investigator decks in investigator mode, defines the spacing for how the\n-- rows and columns are laid out\nlocal INVESTIGATOR_POSITION_SHIFT_ROW = Vector(0, 0, 11)\nlocal INVESTIGATOR_POSITION_SHIFT_COL = Vector(-6, 0, 0)\nlocal INVESTIGATOR_MAX_COLS = 6\n\n-- Positions relative to the minicard to place other stacks. Both signature card piles and starter\n-- decks use SIGNATURE_OFFSET\nlocal INVESTIGATOR_CARD_OFFSET = Vector(0, 0, 2.55)\nlocal INVESTIGATOR_SIGNATURE_OFFSET = Vector(0, 0, 5.75)\n\n-- USE THESE! Positions and offset shifts accounting for the scale of the panel\nlocal startPositions\nlocal cardRowOffset\nlocal cardGroupOffset\nlocal investigatorPositionShiftRow\nlocal investigatorPositionShiftCol\nlocal investigatorCardOffset\nlocal investigatorSignatureOffset\n\nlocal CLASS_LIST = { \"Guardian\", \"Seeker\", \"Rogue\", \"Mystic\", \"Survivor\", \"Neutral\" }\nlocal CYCLE_LIST = {\n \"Core\",\n \"The Dunwich Legacy\",\n \"The Path to Carcosa\",\n \"The Forgotten Age\",\n \"The Circle Undone\",\n \"The Dream-Eaters\",\n \"The Innsmouth Conspiracy\",\n \"Edge of the Earth\",\n \"The Scarlet Keys\",\n \"The Feast of Hemlock Vale\",\n \"Investigator Packs\"\n}\n\nlocal excludedNonBasicWeaknesses\n\nlocal starterDeckMode = STARTER_DECK_MODE_CARDS_ONLY\nlocal helpVisibleToPlayers = { }\n\nfunction onSave()\n return JSON.encode({ spawnBagState = spawnBag.getStateForSave() })\nend\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local saveState = JSON.decode(savedData) or { }\n if saveState.spawnBagState ~= nil then\n spawnBag.loadFromSave(saveState.spawnBagState)\n end\n end\n arkhamDb.initialize()\n buildExcludedWeaknessList()\n createButtons()\nend\n\n-- Build a list of non-basic weaknesses which should be excluded from the last weakness set,\n-- including all signature cards and evolved weaknesses.\nfunction buildExcludedWeaknessList()\n excludedNonBasicWeaknesses = { }\n for _, investigator in pairs(INVESTIGATORS) do\n for _, signatureId in ipairs(investigator.signatures) do\n excludedNonBasicWeaknesses[signatureId] = true\n end\n end\n for _, weaknessId in ipairs(EVOLVED_WEAKNESSES) do\n excludedNonBasicWeaknesses[weaknessId] = true\n end\nend\n\nfunction createButtons()\n createHelpButton()\n createInvestigatorButtons()\n createLevelZeroButtons()\n createUpgradedButtons()\n createWeaknessButtons()\n createOtherButtons()\n createCycleButtons()\n createClearButton()\n -- Create investigator mode buttons last so the indexes are set when we need to update them\n createInvestigatorModeButtons()\nend\n\nfunction createHelpButton()\n self.createButton({\n function_owner = self,\n click_function = \"toggleHelp\",\n position = Vector(0.845, 0.1, -0.855),\n height = 180,\n width = 180,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n })\nend\n\nfunction createInvestigatorButtons()\n local invButtonParams = {\n function_owner = self,\n height = CIRCLE_BUTTON_SIZE,\n width = CIRCLE_BUTTON_SIZE,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n }\n local buttonPos = INVESTIGATOR_ROW_START:copy()\n for _, class in ipairs(CLASS_LIST) do\n invButtonParams.click_function = \"spawnInvestigators\" .. class\n invButtonParams.position = buttonPos\n self.createButton(invButtonParams)\n buttonPos.x = buttonPos.x + CLASS_BUTTONS_X_OFFSET\n self.setVar(invButtonParams.click_function, function(_, _, _) spawnInvestigatorGroup(class) end)\n end\nend\n\nfunction createLevelZeroButtons()\n local l0ButtonParams = {\n function_owner = self,\n height = CIRCLE_BUTTON_SIZE,\n width = CIRCLE_BUTTON_SIZE,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n }\n local buttonPos = LEVEL_ZERO_ROW_START:copy()\n for _, class in ipairs(CLASS_LIST) do\n l0ButtonParams.click_function = \"spawnBasic\" .. class\n l0ButtonParams.position = buttonPos\n self.createButton(l0ButtonParams)\n buttonPos.x = buttonPos.x + CLASS_BUTTONS_X_OFFSET\n self.setVar(l0ButtonParams.click_function, function(_, _, _) spawnClassCards(class, false) end)\n end\nend\n\nfunction createUpgradedButtons()\n local upgradedButtonParams = {\n function_owner = self,\n height = CIRCLE_BUTTON_SIZE,\n width = CIRCLE_BUTTON_SIZE,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n }\n local buttonPos = UPGRADED_ROW_START:copy()\n for _, class in ipairs(CLASS_LIST) do\n upgradedButtonParams.click_function = \"spawnUpgraded\" .. class\n upgradedButtonParams.position = buttonPos\n self.createButton(upgradedButtonParams)\n buttonPos.x = buttonPos.x + CLASS_BUTTONS_X_OFFSET\n self.setVar(upgradedButtonParams.click_function, function(_, _, _) spawnClassCards(class, true) end)\n end\nend\n\nfunction createWeaknessButtons()\n local weaknessButtonParams = {\n function_owner = self,\n height = CIRCLE_BUTTON_SIZE,\n width = CIRCLE_BUTTON_SIZE,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n }\n local buttonPos = WEAKNESS_ROW_START:copy()\n weaknessButtonParams.click_function = \"spawnWeaknesses\"\n weaknessButtonParams.tooltip = \"All Weaknesses\"\n weaknessButtonParams.position = buttonPos\n self.createButton(weaknessButtonParams)\n buttonPos.x = buttonPos.x + MISC_BUTTONS_X_OFFSET\n weaknessButtonParams.click_function = \"spawnRandomWeakness\"\n weaknessButtonParams.tooltip = \"Random Basic Weakness\"\n weaknessButtonParams.position = buttonPos\n self.createButton(weaknessButtonParams)\nend\n\nfunction createOtherButtons()\n local otherButtonParams = {\n function_owner = self,\n height = CIRCLE_BUTTON_SIZE,\n width = CIRCLE_BUTTON_SIZE,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n }\n local buttonPos = OTHER_ROW_START:copy()\n otherButtonParams.click_function = \"spawnBonded\"\n otherButtonParams.tooltip = \"Bonded Cards\"\n otherButtonParams.position = buttonPos\n self.createButton(otherButtonParams)\n buttonPos.x = buttonPos.x + MISC_BUTTONS_X_OFFSET\n otherButtonParams.click_function = \"spawnUpgradeSheets\"\n otherButtonParams.tooltip = \"Customization Upgrade Sheets\"\n otherButtonParams.position = buttonPos\n self.createButton(otherButtonParams)\nend\n\nfunction createCycleButtons()\n local cycleButtonParams = {\n function_owner = self,\n height = CYCLE_BUTTON_SIZE,\n width = CYCLE_BUTTON_SIZE,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n }\n local buttonPos = CYCLE_BUTTON_START:copy()\n local rowCount = 0\n local colCount = 0\n for _, cycle in ipairs(CYCLE_LIST) do\n cycleButtonParams.click_function = \"spawnCycle\" .. cycle\n cycleButtonParams.position = buttonPos\n cycleButtonParams.tooltip = cycle\n self.createButton(cycleButtonParams)\n self.setVar(cycleButtonParams.click_function, function(_, _, _) spawnCycle(cycle) end)\n colCount = colCount + 1\n -- If we've reached the end of a row, shift down and back to the first column\n if colCount \u003e= CYCLE_COLUMN_COUNT then\n buttonPos = CYCLE_BUTTON_START:copy()\n rowCount = rowCount + 1\n colCount = 0\n buttonPos.z = buttonPos.z + CYCLE_BUTTONS_Z_OFFSET * rowCount\n if rowCount == 3 then\n -- Account for two centered buttons on the final row\n buttonPos.x = buttonPos.x + CYCLE_BUTTONS_X_OFFSET / 2\n --[[ Account for centered button on the final row\n buttonPos.x = buttonPos.x + CYCLE_BUTTONS_X_OFFSET\n ]]\n end\n else\n buttonPos.x = buttonPos.x + CYCLE_BUTTONS_X_OFFSET\n end\n end\nend\n\nfunction createClearButton()\n self.createButton({\n function_owner = self,\n click_function = \"deleteAll\",\n position = Vector(0, 0.1, 0.852),\n height = 170,\n width = 750,\n scale = Vector(0.25, 1, 0.25),\n color = TRANSPARENT\n })\nend\n\nfunction createInvestigatorModeButtons()\n local starterMode = starterDeckMode == STARTER_DECK_MODE_STARTERS\n\n self.createButton({\n function_owner = self,\n click_function = \"setCardsOnlyMode\",\n position = Vector(0.251, 0.1, -0.322),\n height = 170,\n width = 760,\n scale = Vector(0.25, 1, 0.25),\n color = starterMode and TRANSPARENT or STARTER_DECK_MODE_SELECTED_COLOR\n })\n self.createButton({\n function_owner = self,\n click_function = \"setStarterDeckMode\",\n position = Vector(0.66, 0.1, -0.322),\n height = 170,\n width = 760,\n scale = Vector(0.25, 1, 0.25),\n color = starterMode and STARTER_DECK_MODE_SELECTED_COLOR or TRANSPARENT\n })\n local checkX = starterMode and 0.52 or 0.11\n self.createButton({\n function_owner = self,\n label = \"✓\",\n click_function = \"doNothing\",\n position = Vector(checkX, 0.11, -0.317),\n height = 0,\n width = 0,\n scale = Vector(0.3, 1, 0.3),\n font_color = { 0, 0, 0 },\n color = { 1, 1, 1 }\n })\nend\n\nfunction toggleHelp(_, playerColor, _)\n if helpVisibleToPlayers[playerColor] then\n helpVisibleToPlayers[playerColor] = nil\n else\n helpVisibleToPlayers[playerColor] = true\n end\n updateHelpVisibility()\nend\n\nfunction updateHelpVisibility()\n local visibility = \"\"\n for player, _ in pairs(helpVisibleToPlayers) do\n if string.len(visibility) \u003e 0 then\n visibility = visibility .. \"|\" .. player\n else\n visibility = player\n end\n end\n self.UI.setAttribute(\"helpText\", \"visibility\", visibility)\n self.UI.setAttribute(\"helpPanel\", \"visibility\", visibility)\n self.UI.setAttribute(\"helpPanel\", \"active\", string.len(visibility) \u003e 0)\nend\n\nfunction setStarterDeckMode()\n starterDeckMode = STARTER_DECK_MODE_STARTERS\n updateStarterModeButtons()\nend\n\nfunction setCardsOnlyMode()\n starterDeckMode = STARTER_DECK_MODE_CARDS_ONLY\n updateStarterModeButtons()\nend\n\nfunction updateStarterModeButtons()\n local buttonCount = #self.getButtons()\n -- Buttons are 0-indexed, so the last three are -1, -2, and -3 from the size\n self.removeButton(buttonCount - 1)\n self.removeButton(buttonCount - 2)\n self.removeButton(buttonCount - 3)\n createInvestigatorModeButtons()\nend\n\n-- Clears the table and updates positions based on scale (should be called before ANY card placement)\nfunction prepareToPlaceCards()\n deleteAll()\n scalePositions()\nend\n\n-- Updates the positions based on the current object scale to ensure the relative layout functions\n-- properly at different scales.\nfunction scalePositions()\n -- Assume scaling is consistent in X and Z dimensions\n local scale = 1 / self.getScale().x\n startPositions = { }\n for key, pos in pairs(START_POSITIONS) do\n -- Because a scaled object means a different global size, using global distance for Z results in\n -- the cards being closer or farther depending on the scale. Leave the Z values and only scale X and Y\n startPositions[key] = Vector(pos)\n startPositions[key].x = startPositions[key].x * scale\n startPositions[key].y = startPositions[key].y * scale\n end\n cardRowOffset = CARD_ROW_OFFSET * scale\n cardGroupOffset = CARD_GROUP_OFFSET * scale\n investigatorPositionShiftRow = Vector(INVESTIGATOR_POSITION_SHIFT_ROW):scale(scale)\n investigatorPositionShiftCol = Vector(INVESTIGATOR_POSITION_SHIFT_COL):scale(scale)\n investigatorCardOffset = Vector(INVESTIGATOR_CARD_OFFSET):scale(scale)\n investigatorSignatureOffset = Vector(INVESTIGATOR_SIGNATURE_OFFSET):scale(scale)\nend\n\n-- Deletes all cards currently placed on the table\nfunction deleteAll()\n spawnBag.recall(true)\nend\n\n-- Spawn an investigator group, based on the current UI setting for either investigators or starter\n-- decks.\n---@param groupName string Name of the group to spawn, matching a key in InvestigatorPanelData\nfunction spawnInvestigatorGroup(groupName)\n local starterMode = starterDeckMode == STARTER_DECK_MODE_STARTERS\n prepareToPlaceCards()\n Wait.frames(function()\n if starterMode then\n spawnStarters(groupName)\n else\n spawnInvestigators(groupName)\n end\n end, 2)\nend\n\n-- Spawn cards for all investigators in the given group. This creates piles for all defined\n-- investigator cards and minicards as well as the signature cards.\n---@param groupName string Name of the group to spawn, matching a key in InvestigatorPanelData\nfunction spawnInvestigators(groupName)\n if INVESTIGATOR_GROUPS[groupName] == nil then\n printToAll(\"No \" .. groupName .. \" data yet\")\n return\n end\n\n local col = 1\n local row = 1\n local investigatorCount = #INVESTIGATOR_GROUPS[groupName]\n local position = getInvestigatorRowStartPos(investigatorCount, row)\n\n for i, investigatorName in ipairs(INVESTIGATOR_GROUPS[groupName]) do\n for _, spawnSpec in ipairs(buildInvestigatorSpawnSpec(investigatorName, INVESTIGATORS[investigatorName], position)) do\n spawnBag.spawn(spawnSpec)\n end\n position:add(investigatorPositionShiftCol)\n col = col + 1\n if col \u003e INVESTIGATOR_MAX_COLS then\n col = 1\n row = row + 1\n position = getInvestigatorRowStartPos(investigatorCount, row)\n end\n end\nend\n\nfunction getInvestigatorRowStartPos(investigatorCount, row)\n local rowStart = Vector(startPositions.investigator)\n rowStart:add(Vector(\n investigatorPositionShiftRow.x * (row - 1),\n investigatorPositionShiftRow.y * (row - 1),\n investigatorPositionShiftRow.z * (row - 1)))\n local investigatorsInRow = math.min(investigatorCount - INVESTIGATOR_MAX_COLS * (row - 1), INVESTIGATOR_MAX_COLS)\n rowStart:add(Vector(\n investigatorPositionShiftCol.x * (INVESTIGATOR_MAX_COLS - investigatorsInRow) / 2,\n investigatorPositionShiftCol.y * (INVESTIGATOR_MAX_COLS - investigatorsInRow) / 2,\n investigatorPositionShiftCol.z * (INVESTIGATOR_MAX_COLS - investigatorsInRow) / 2))\n return rowStart\nend\n\n-- Creates the spawn spec for the investigator's signature cards.\n---@param investigatorName string Name of the investigator, matching a key in InvestigatorPanelData\n---@param investigatorData table Spawn definition for the investigator, retrieved from INVESTIGATORS\n---@param position tts__Vector Where to spawn the minicard; investigagor cards will be placed below\nfunction buildInvestigatorSpawnSpec(investigatorName, investigatorData, position)\n local sigPos = Vector(position):add(investigatorSignatureOffset)\n local spawns = buildCommonSpawnSpec(investigatorName, investigatorData, position)\n table.insert(spawns, {\n name = investigatorName .. \"signatures\",\n cards = investigatorData.signatures,\n globalPos = self.positionToWorld(sigPos),\n rotation = FACE_UP_ROTATION\n })\n\n return spawns\nend\n\n-- Builds the spawn specs for minicards and investigator cards. These are common enough to be\n-- shared, and will only differ in whether they spawn the full stack of possible investigator and\n-- minicards, or only the first of each.\n---@param investigatorName string Name of the investigator, matching a key in InvestigatorPanelData\n---@param investigatorData table Spawn definition for the investigator, retrieved from INVESTIGATORS\n---@param position tts__Vector Where to spawn the minicard; investigagor cards will be placed below\n---@param oneCardOnly? boolean If true, will spawn only the first card in the investigator card\n--- and minicard lists. Otherwise, spawn them all in a deck\nfunction buildCommonSpawnSpec(investigatorName, investigatorData, position, oneCardOnly)\n local cardPos = Vector(position):add(investigatorCardOffset)\n return {\n {\n name = investigatorName .. \"minicards\",\n cards = oneCardOnly and { investigatorData.minicards[1] } or investigatorData.minicards,\n globalPos = self.positionToWorld(position),\n rotation = FACE_UP_ROTATION\n },\n {\n name = investigatorName .. \"cards\",\n cards = oneCardOnly and { investigatorData.cards[1] } or investigatorData.cards,\n globalPos = self.positionToWorld(cardPos),\n rotation = FACE_UP_ROTATION\n }\n }\nend\n\n-- Spawns all starter decks (single minicard and investigator card, plus the starter deck) for\n-- investigators in the given group.\n---@param groupName string Name of the group to spawn, matching a key in InvestigatorPanelData\nfunction spawnStarters(groupName)\n local col = 1\n local row = 1\n local investigatorCount = #INVESTIGATOR_GROUPS[groupName]\n local position = getInvestigatorRowStartPos(investigatorCount, row)\n for _, investigatorName in ipairs(INVESTIGATOR_GROUPS[groupName]) do\n spawnStarterDeck(investigatorName, INVESTIGATORS[investigatorName], position)\n position:add(investigatorPositionShiftCol)\n col = col + 1\n if col \u003e INVESTIGATOR_MAX_COLS then\n col = 1\n row = row + 1\n position = getInvestigatorRowStartPos(investigatorCount, row)\n end\n end\nend\n\n-- Spawns the defined starter deck for the given investigator's.\n---@param investigatorName string Name of the investigator, matching a key in InvestigatorPanelData\nfunction spawnStarterDeck(investigatorName, investigatorData, position)\n for _, spawnSpec in ipairs(buildCommonSpawnSpec(investigatorName, investigatorData, position, true)) do\n spawnBag.spawn(spawnSpec)\n end\n local deckPos = Vector(position):add(investigatorSignatureOffset)\n arkhamDb.getDecklist(\"None\", investigatorData.starterDeck, true, false, false, function(slots)\n local cardIdList = { }\n for id, count in pairs(slots) do\n for i = 1, count do\n table.insert(cardIdList, id)\n end\n end\n spawnBag.spawn({\n name = investigatorName..\"starter\",\n cards = cardIdList,\n globalPos = self.positionToWorld(deckPos),\n rotation = FACE_DOWN_ROTATION\n })\n end)\nend\n-- Clears the currently placed cards, then places cards for the given class and level spread\n---@param cardClass string Class to place (\"Guardian\", \"Seeker\", etc)\n---@param isUpgraded boolean If true, spawn the Level 1-5 cards. Otherwise, Level 0.\nfunction spawnClassCards(cardClass, isUpgraded)\n prepareToPlaceCards()\n Wait.frames(function() placeClassCards(cardClass, isUpgraded) end, 2)\nend\n\n-- Spawn the class cards.\n---@param cardClass string Class to place (\"Guardian\", \"Seeker\", etc)\n---@param isUpgraded boolean If true, spawn the Level 1-5 cards. Otherwise, Level 0.\nfunction placeClassCards(cardClass, isUpgraded)\n local indexReady = allCardsBagApi.isIndexReady()\n if (not indexReady) then\n broadcastToAll(\"Still loading player cards, please try again in a few seconds\", {0.9, 0.2, 0.2})\n return\n end\n local cardIdList = allCardsBagApi.getCardsByClassAndLevel(cardClass, isUpgraded)\n\n local skillList = { }\n local eventList = { }\n local assetList = { }\n for _, cardId in ipairs(cardIdList) do\n local cardMetadata = allCardsBagApi.getCardById(cardId).metadata\n if (cardMetadata.type == \"Skill\") then\n table.insert(skillList, cardId)\n elseif (cardMetadata.type == \"Event\") then\n table.insert(eventList, cardId)\n elseif (cardMetadata.type == \"Asset\") then\n table.insert(assetList, cardId)\n end\n end\n local groupPos = Vector(startPositions.classCards)\n if #skillList \u003e 0 then\n spawnBag.spawn({\n name = cardClass .. (isUpgraded and \"upgraded\" or \"basic\"),\n cards = skillList,\n globalPos = self.positionToWorld(groupPos),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\n groupPos.z = groupPos.z + math.ceil(#skillList / 20) * cardRowOffset + cardGroupOffset\n end\n if #eventList \u003e 0 then\n spawnBag.spawn({\n name = cardClass .. \"event\" .. (isUpgraded and \"upgraded\" or \"basic\"),\n cards = eventList,\n globalPos = self.positionToWorld(groupPos),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\n groupPos.z = groupPos.z + math.ceil(#eventList / 20) * cardRowOffset + cardGroupOffset\n end\n if #assetList \u003e 0 then\n spawnBag.spawn({\n name = cardClass .. \"asset\" .. (isUpgraded and \"upgraded\" or \"basic\"),\n cards = assetList,\n globalPos = self.positionToWorld(groupPos),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\n end\nend\n\n-- Spawns the investigator sets and all cards for the given cycle\n---@param cycle string Name of a cycle, should match the standard used in card metadata\nfunction spawnCycle(cycle)\n prepareToPlaceCards()\n spawnInvestigators(cycle)\n local indexReady = allCardsBagApi.isIndexReady()\n if (not indexReady) then\n broadcastToAll(\"Still loading player cards, please try again in a few seconds\", {0.9, 0.2, 0.2})\n return\n end\n local cycleCardList = allCardsBagApi.getCardsByCycle(cycle)\n local copiedList = { }\n for i, id in ipairs(cycleCardList) do\n copiedList[i] = id\n end\n spawnBag.spawn({\n name = \"cycle\"..cycle,\n cards = copiedList,\n globalPos = self.positionToWorld(startPositions.cycle),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\nend\n\nfunction spawnBonded()\n prepareToPlaceCards()\n spawnBag.spawn({\n name = \"bonded\",\n cards = BONDED_CARD_LIST,\n globalPos = self.positionToWorld(startPositions.classCards),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\nend\n\nfunction spawnUpgradeSheets()\n prepareToPlaceCards()\n spawnBag.spawn({\n name = \"upgradeSheets\",\n cards = UPGRADE_SHEET_LIST,\n globalPos = self.positionToWorld(startPositions.classCards),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\n spawnBag.spawn({\n name = \"servitor\",\n cards = { \"09080-m\" },\n globalPos = self.positionToWorld(startPositions.summonedServitor),\n rotation = FACE_UP_ROTATION,\n })\nend\n\n-- Clears the current cards, and places all basic weaknesses on the table.\nfunction spawnWeaknesses()\n prepareToPlaceCards()\n local indexReady = allCardsBagApi.isIndexReady()\n if (not indexReady) then\n broadcastToAll(\"Still loading player cards, please try again in a few seconds\", {0.9, 0.2, 0.2})\n return\n end\n local weaknessIdList = allCardsBagApi.getUniqueWeaknesses()\n local basicWeaknessList = { }\n local otherWeaknessList = { }\n for i, id in ipairs(weaknessIdList) do\n local cardMetadata = allCardsBagApi.getCardById(id).metadata\n if cardMetadata.basicWeaknessCount ~= nil and cardMetadata.basicWeaknessCount \u003e 0 then\n table.insert(basicWeaknessList, id)\n elseif excludedNonBasicWeaknesses[id] == nil then\n table.insert(otherWeaknessList, id)\n end\n end\n local groupPos = Vector(startPositions.classCards)\n spawnBag.spawn({\n name = \"basicWeaknesses\",\n cards = basicWeaknessList,\n globalPos = self.positionToWorld(groupPos),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\n groupPos.z = groupPos.z + math.ceil(#basicWeaknessList / 20) * cardRowOffset + cardGroupOffset\n spawnBag.spawn({\n name = \"evolvedWeaknesses\",\n cards = EVOLVED_WEAKNESSES,\n globalPos = self.positionToWorld(groupPos),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\n groupPos.z = groupPos.z + math.ceil(#EVOLVED_WEAKNESSES / 20) * cardRowOffset + cardGroupOffset\n spawnBag.spawn({\n name = \"otherWeaknesses\",\n cards = otherWeaknessList,\n globalPos = self.positionToWorld(groupPos),\n rotation = FACE_UP_ROTATION,\n spread = true,\n spreadCols = 20\n })\nend\n\nfunction spawnRandomWeakness()\n prepareToPlaceCards()\n local weaknessId = allCardsBagApi.getRandomWeaknessId()\n if (weaknessId == nil) then\n broadcastToAll(\"All basic weaknesses are in play!\", {0.9, 0.2, 0.2})\n return\n end\n spawnBag.spawn({\n name = \"randomWeakness\",\n cards = { weaknessId },\n globalPos = self.positionToWorld(startPositions.randomWeakness),\n rotation = FACE_UP_ROTATION,\n })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "{\"spawnBagState\":{\"placed\":[],\"placedObjects\":[]}}", "MeasureMovement": false, "Name": "Custom_Tile", @@ -199746,7 +202906,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"util/TokenRemover\")\nend)\n__bundle_register(\"util/TokenRemover\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal zone = nil\n\n-- general code\nfunction onSave()\n return JSON.encode(zone and zone.getGUID() or nil)\nend\n\nfunction onLoad(savedData)\n if savedData ~= \"\" and savedData ~= nil then\n zone = getObjectFromGUID(JSON.decode(savedData))\n end\n setMenu(zone == nil)\nend\n\n-- context menu functions\nfunction enable()\n local scale = self.getScale()\n zone = spawnObject({\n type = \"ScriptingTrigger\",\n position = self.getPosition() + Vector(0, 3.5 + 0.11, 0),\n rotation = self.getRotation(),\n scale = { scale.x * 2, 7, scale.z * 2 }\n })\n zone.setName(\"TokenDiscardZone\")\n setMenu(false)\nend\n\nfunction disable()\n if zone ~= nil then zone.destruct() end\n setMenu(true)\nend\n\n-- core functions\nfunction setMenu(isEnabled)\n self.clearContextMenu()\n if isEnabled then\n self.addContextMenuItem(\"Enable\", enable)\n else\n self.addContextMenuItem(\"Disable\", disable)\n end\nend\n\nfunction onPickUp()\n disable()\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"util/TokenRemover\")\nend)\n__bundle_register(\"util/TokenRemover\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal zone\n\n-- general code\nfunction onSave()\n return JSON.encode(zone and zone.getGUID())\nend\n\nfunction onLoad(savedData)\n if savedData ~= \"\" and savedData ~= nil then\n zone = getObjectFromGUID(JSON.decode(savedData))\n end\n setMenu(zone == nil)\nend\n\n-- context menu functions\nfunction enable()\n local scale = self.getScale()\n zone = spawnObject({\n type = \"ScriptingTrigger\",\n position = self.getPosition() + Vector(0, 3.5 + 0.11, 0),\n rotation = self.getRotation(),\n scale = { scale.x * 2, 7, scale.z * 2 }\n })\n zone.setName(\"TokenDiscardZone\")\n setMenu(false)\nend\n\nfunction disable()\n if zone ~= nil then zone.destruct() end\n setMenu(true)\nend\n\n-- core functions\nfunction setMenu(isEnabled)\n self.clearContextMenu()\n if isEnabled then\n self.addContextMenuItem(\"Enable\", enable)\n else\n self.addContextMenuItem(\"Disable\", disable)\n end\nend\n\nfunction onPickUp()\n disable()\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "null", "MeasureMovement": false, "Name": "Custom_Tile", @@ -199806,7 +202966,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"util/TokenRemover\")\nend)\n__bundle_register(\"util/TokenRemover\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal zone = nil\n\n-- general code\nfunction onSave()\n return JSON.encode(zone and zone.getGUID() or nil)\nend\n\nfunction onLoad(savedData)\n if savedData ~= \"\" and savedData ~= nil then\n zone = getObjectFromGUID(JSON.decode(savedData))\n end\n setMenu(zone == nil)\nend\n\n-- context menu functions\nfunction enable()\n local scale = self.getScale()\n zone = spawnObject({\n type = \"ScriptingTrigger\",\n position = self.getPosition() + Vector(0, 3.5 + 0.11, 0),\n rotation = self.getRotation(),\n scale = { scale.x * 2, 7, scale.z * 2 }\n })\n zone.setName(\"TokenDiscardZone\")\n setMenu(false)\nend\n\nfunction disable()\n if zone ~= nil then zone.destruct() end\n setMenu(true)\nend\n\n-- core functions\nfunction setMenu(isEnabled)\n self.clearContextMenu()\n if isEnabled then\n self.addContextMenuItem(\"Enable\", enable)\n else\n self.addContextMenuItem(\"Disable\", disable)\n end\nend\n\nfunction onPickUp()\n disable()\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"util/TokenRemover\")\nend)\n__bundle_register(\"util/TokenRemover\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal zone\n\n-- general code\nfunction onSave()\n return JSON.encode(zone and zone.getGUID())\nend\n\nfunction onLoad(savedData)\n if savedData ~= \"\" and savedData ~= nil then\n zone = getObjectFromGUID(JSON.decode(savedData))\n end\n setMenu(zone == nil)\nend\n\n-- context menu functions\nfunction enable()\n local scale = self.getScale()\n zone = spawnObject({\n type = \"ScriptingTrigger\",\n position = self.getPosition() + Vector(0, 3.5 + 0.11, 0),\n rotation = self.getRotation(),\n scale = { scale.x * 2, 7, scale.z * 2 }\n })\n zone.setName(\"TokenDiscardZone\")\n setMenu(false)\nend\n\nfunction disable()\n if zone ~= nil then zone.destruct() end\n setMenu(true)\nend\n\n-- core functions\nfunction setMenu(isEnabled)\n self.clearContextMenu()\n if isEnabled then\n self.addContextMenuItem(\"Enable\", enable)\n else\n self.addContextMenuItem(\"Disable\", disable)\n end\nend\n\nfunction onPickUp()\n disable()\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "null", "MeasureMovement": false, "Name": "Custom_Tile", @@ -199866,7 +203026,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"util/TokenRemover\")\nend)\n__bundle_register(\"util/TokenRemover\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal zone = nil\n\n-- general code\nfunction onSave()\n return JSON.encode(zone and zone.getGUID() or nil)\nend\n\nfunction onLoad(savedData)\n if savedData ~= \"\" and savedData ~= nil then\n zone = getObjectFromGUID(JSON.decode(savedData))\n end\n setMenu(zone == nil)\nend\n\n-- context menu functions\nfunction enable()\n local scale = self.getScale()\n zone = spawnObject({\n type = \"ScriptingTrigger\",\n position = self.getPosition() + Vector(0, 3.5 + 0.11, 0),\n rotation = self.getRotation(),\n scale = { scale.x * 2, 7, scale.z * 2 }\n })\n zone.setName(\"TokenDiscardZone\")\n setMenu(false)\nend\n\nfunction disable()\n if zone ~= nil then zone.destruct() end\n setMenu(true)\nend\n\n-- core functions\nfunction setMenu(isEnabled)\n self.clearContextMenu()\n if isEnabled then\n self.addContextMenuItem(\"Enable\", enable)\n else\n self.addContextMenuItem(\"Disable\", disable)\n end\nend\n\nfunction onPickUp()\n disable()\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"util/TokenRemover\")\nend)\n__bundle_register(\"util/TokenRemover\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal zone\n\n-- general code\nfunction onSave()\n return JSON.encode(zone and zone.getGUID())\nend\n\nfunction onLoad(savedData)\n if savedData ~= \"\" and savedData ~= nil then\n zone = getObjectFromGUID(JSON.decode(savedData))\n end\n setMenu(zone == nil)\nend\n\n-- context menu functions\nfunction enable()\n local scale = self.getScale()\n zone = spawnObject({\n type = \"ScriptingTrigger\",\n position = self.getPosition() + Vector(0, 3.5 + 0.11, 0),\n rotation = self.getRotation(),\n scale = { scale.x * 2, 7, scale.z * 2 }\n })\n zone.setName(\"TokenDiscardZone\")\n setMenu(false)\nend\n\nfunction disable()\n if zone ~= nil then zone.destruct() end\n setMenu(true)\nend\n\n-- core functions\nfunction setMenu(isEnabled)\n self.clearContextMenu()\n if isEnabled then\n self.addContextMenuItem(\"Enable\", enable)\n else\n self.addContextMenuItem(\"Disable\", disable)\n end\nend\n\nfunction onPickUp()\n disable()\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "null", "MeasureMovement": false, "Name": "Custom_Tile", @@ -201213,7 +204373,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/VictoryDisplay\")\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/VictoryDisplay\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal searchLib = require(\"util/SearchLib\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playAreaApi = require(\"core/PlayAreaApi\")\nlocal tokenChecker = require(\"core/token/TokenChecker\")\n\nlocal pendingCall = false\nlocal missingData = {}\nlocal countedVP = {}\n\nlocal highlightMissing = false\nlocal highlightCounted = false\n\n-- button creation when loading the game\nfunction onLoad()\n -- index 0: VP - \"Display\"\n local buttonParameters = {}\n buttonParameters.label = \"0\"\n buttonParameters.click_function = \"none\"\n buttonParameters.function_owner = self\n buttonParameters.scale = { 0.15, 0.15, 0.15 }\n buttonParameters.width = 0\n buttonParameters.height = 0\n buttonParameters.font_size = 600\n buttonParameters.font_color = { 1, 1, 1 }\n buttonParameters.position = { x = -0.72, y = 0.06, z = -0.69 }\n self.createButton(buttonParameters)\n\n -- index 1: VP - \"Play Area\"\n buttonParameters.position.x = 0.65\n self.createButton(buttonParameters)\n\n -- index 2: VP - \"Total\"\n buttonParameters.position.x = 1.69\n self.createButton(buttonParameters)\n\n -- index 3: highlighting button (missing data)\n buttonParameters.label = \"!\"\n buttonParameters.click_function = \"highlightMissingData\"\n buttonParameters.tooltip = \"Enable highlighting of cards without metadata (VP on these is not counted).\"\n buttonParameters.color = { 1, 0, 0 }\n buttonParameters.width = 700\n buttonParameters.height = 800\n buttonParameters.font_size = 700\n buttonParameters.position = { x = 1.82, y = 0.06, z = -1.32 }\n self.createButton(buttonParameters)\n\n -- index 4: highlighting button (counted VP)\n buttonParameters.label = \"?\"\n buttonParameters.click_function = \"highlightCountedVP\"\n buttonParameters.tooltip = \"Enable highlighting of cards with VP.\"\n buttonParameters.color = { 0, 1, 0 }\n buttonParameters.position.x = 1.5\n self.createButton(buttonParameters)\n\n -- update the display label once\n Wait.time(updateCount, 1)\nend\n\n---------------------------------------------------------\n-- events with descriptions\n---------------------------------------------------------\n\n-- dropping an object on the victory display\nfunction onCollisionEnter()\n startUpdate()\nend\n\n-- removing an object from the victory display\nfunction onCollisionExit()\n startUpdate()\nend\n\n-- picking a clue or location up\nfunction onObjectPickUp(_, obj)\n maybeUpdate(obj)\nend\n\n-- dropping a clue or location\nfunction onObjectDrop(_, obj)\n maybeUpdate(obj, 1)\nend\n\n-- flipping a clue/doom or location\nfunction onObjectRotate(obj, _, flip, _, _, oldFlip)\n if flip == oldFlip then return end\n maybeUpdate(obj, 1, true)\nend\n\n-- destroying a clue or location\nfunction onObjectDestroy(obj)\n maybeUpdate(obj)\nend\n\n---------------------------------------------------------\n-- main functionality\n---------------------------------------------------------\n\nfunction maybeUpdate(obj, delay, flipped)\n -- stop if there is already an update call running\n if pendingCall then return end\n\n -- stop if obj is nil (by e.g. dropping a clue onto another and making a stack)\n if obj == nil then return end\n\n -- only continue for clues / doom tokens or locations\n if obj.hasTag(\"Location\") then\n elseif obj.memo == \"clueDoom\" then\n -- only continue if the clue side is up or a doom token is being flipped\n if obj.is_face_down == true and flipped ~= true then return end\n else\n return\n end\n\n -- only continue if the obj in in the play area\n if not playAreaApi.isInPlayArea(obj) then return end\n\n startUpdate(delay)\nend\n\n-- starts an update\nfunction startUpdate(delay)\n -- stop if there is already an update call running\n if pendingCall then return end\n pendingCall = true\n delay = tonumber(delay) or 0\n Wait.time(updateCount, delay + 0.2)\nend\n\n-- counts the VP in the victory display and request the VP count from the play area\nfunction updateCount()\n missingData = {}\n countedVP = {}\n local victoryPoints = {}\n victoryPoints.display = 0\n victoryPoints.playArea = playAreaApi.countVP()\n\n -- count cards in victory display\n for _, obj in ipairs(searchLib.onObject(self, \"isCardOrDeck\")) do\n -- check metadata for VP\n if obj.type == \"Card\" then\n local VP = getCardVP(obj, JSON.decode(obj.getGMNotes()))\n victoryPoints.display = victoryPoints.display + VP\n if VP \u003e 0 then\n table.insert(countedVP, obj)\n end\n\n -- handling for stacked cards\n elseif obj.type == \"Deck\" then\n local VP = 0\n for _, deepObj in ipairs(obj.getObjects()) do\n local deepVP = getCardVP(obj, JSON.decode(deepObj.gm_notes))\n victoryPoints.display = victoryPoints.display + deepVP\n if deepVP \u003e 0 then\n VP = VP + 1\n end\n end\n if VP \u003e 0 then\n table.insert(countedVP, obj)\n end\n end\n end\n\n -- update the buttons that are used as labels\n self.editButton({ index = 0, label = victoryPoints.display })\n self.editButton({ index = 1, label = victoryPoints.playArea })\n self.editButton({ index = 2, label = victoryPoints.display + victoryPoints.playArea })\n\n -- allow new update calls\n pendingCall = false\nend\n\n-- gets the VP count from the notes\nfunction getCardVP(obj, notes)\n local cardVP\n if notes ~= nil then\n -- enemy, treachery etc.\n cardVP = tonumber(notes.victory)\n\n -- location\n if not cardVP then\n -- check the correct side of the location\n if not obj.is_face_down and notes.locationFront ~= nil then\n cardVP = tonumber(notes.locationFront.victory)\n elseif notes.locationBack ~= nil then\n cardVP = tonumber(notes.locationBack.victory)\n end\n end\n if (cardVP or 0) \u003e 0 then\n table.insert(countedVP, obj)\n end\n else\n table.insert(missingData, obj)\n end\n return cardVP or 0\nend\n\n-- toggles the highlight for objects with missing metadata\nfunction highlightMissingData()\n self.editButton({\n index = 3,\n tooltip = (highlightMissing and \"Enable\" or \"Disable\") .. \" highlighting of cards without metadata (VP on these is not counted).\" })\n for _, obj in pairs(missingData) do\n if obj ~= nil then\n if highlightMissing then\n obj.highlightOff(\"Red\")\n else\n obj.highlightOn(\"Red\")\n end\n end\n end\n playAreaApi.highlightMissingData(highlightMissing)\n highlightMissing = not highlightMissing\nend\n\n-- toggles the highlight for objects that were counted\nfunction highlightCountedVP()\n self.editButton({\n index = 4,\n tooltip = (highlightCounted and \"Enable\" or \"Disable\") .. \" highlighting of cards with VP.\"\n })\n for _, obj in pairs(countedVP) do\n if obj ~= nil then\n if highlightCounted then\n obj.highlightOff(\"Green\")\n else\n obj.highlightOn(\"Green\")\n end\n end\n end\n playAreaApi.highlightCountedVP(highlightCounted)\n highlightCounted = not highlightCounted\nend\n\n-- places the provided card in the first empty spot\nfunction placeCard(card)\n local trash = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"Trash\")\n\n -- check snap point states\n local snaps = self.getSnapPoints()\n table.sort(snaps, function(a, b) return a.position.x \u003e b.position.x end)\n table.sort(snaps, function(a, b) return a.position.z \u003c b.position.z end)\n\n -- get first empty slot\n local fullSlots = {}\n local positions = {}\n for i, snap in ipairs(snaps) do\n positions[i] = self.positionToWorld(snap.position)\n local searchResult = searchLib.atPosition(positions[i], \"isCardOrDeck\")\n fullSlots[i] = #searchResult \u003e 0\n end\n\n -- remove tokens from the card\n for _, obj in ipairs(searchLib.onObject(card)) do\n -- don't touch decks / cards\n if obj.type == \"Deck\" or obj.type == \"Card\" then\n -- put chaos tokens back into bag\n elseif tokenChecker.isChaosToken(obj) then\n local chaosBag = chaosBagApi.findChaosBag()\n chaosBag.putObject(obj)\n elseif obj.memo ~= nil and obj.getLock() == false then\n trash.putObject(obj)\n end\n end\n\n -- place the card\n local name = card.getName() or \"Unnamed card\"\n for i = 1, 10 do\n if fullSlots[i] ~= true then\n local rot = { 0, 270, card.getRotation().z }\n card.setPositionSmooth(positions[i], false, true)\n card.setRotation(rot)\n broadcastToAll(\"Victory Display: \" .. name .. \" placed into slot \" .. i .. \".\", \"Green\")\n return\n end\n end\n\n broadcastToAll(\"Victory Display is full! \" .. name .. \" placed into slot 1.\", \"Orange\")\n card.setPositionSmooth(positions[1], false, true)\nend\nend)\n__bundle_register(\"core/token/TokenChecker\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local CHAOS_TOKEN_NAMES = {\n [\"Elder Sign\"] = true,\n [\"+1\"] = true,\n [\"0\"] = true,\n [\"-1\"] = true,\n [\"-2\"] = true,\n [\"-3\"] = true,\n [\"-4\"] = true,\n [\"-5\"] = true,\n [\"-6\"] = true,\n [\"-7\"] = true,\n [\"-8\"] = true,\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n [\"Auto-fail\"] = true,\n [\"Bless\"] = true,\n [\"Curse\"] = true,\n [\"Frost\"] = true\n }\n\n local TokenChecker = {}\n\n -- returns true if the passed object is a chaos token (by name)\n TokenChecker.isChaosToken = function(obj)\n if obj.type == \"Tile\" and CHAOS_TOKEN_NAMES[obj.getName()] then\n return true\n else\n return false\n end\n end\n\n return TokenChecker\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/VictoryDisplay\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal searchLib = require(\"util/SearchLib\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playAreaApi = require(\"core/PlayAreaApi\")\nlocal tokenChecker = require(\"core/token/TokenChecker\")\n\nlocal pendingCall = false\nlocal missingData = {}\nlocal countedVP = {}\n\nlocal highlightMissing = false\nlocal highlightCounted = false\n\n-- button creation when loading the game\nfunction onLoad()\n -- index 0: VP - \"Display\"\n local buttonParameters = {}\n buttonParameters.label = \"0\"\n buttonParameters.click_function = \"none\"\n buttonParameters.function_owner = self\n buttonParameters.scale = { 0.15, 0.15, 0.15 }\n buttonParameters.width = 0\n buttonParameters.height = 0\n buttonParameters.font_size = 600\n buttonParameters.font_color = { 1, 1, 1 }\n buttonParameters.position = { x = -0.72, y = 0.06, z = -0.69 }\n self.createButton(buttonParameters)\n\n -- index 1: VP - \"Play Area\"\n buttonParameters.position.x = 0.65\n self.createButton(buttonParameters)\n\n -- index 2: VP - \"Total\"\n buttonParameters.position.x = 1.69\n self.createButton(buttonParameters)\n\n -- index 3: highlighting button (missing data)\n buttonParameters.label = \"!\"\n buttonParameters.click_function = \"highlightMissingData\"\n buttonParameters.tooltip = \"Enable highlighting of cards without metadata (VP on these is not counted).\"\n buttonParameters.color = { 1, 0, 0 }\n buttonParameters.width = 700\n buttonParameters.height = 800\n buttonParameters.font_size = 700\n buttonParameters.position = { x = 1.82, y = 0.06, z = -1.32 }\n self.createButton(buttonParameters)\n\n -- index 4: highlighting button (counted VP)\n buttonParameters.label = \"?\"\n buttonParameters.click_function = \"highlightCountedVP\"\n buttonParameters.tooltip = \"Enable highlighting of cards with VP.\"\n buttonParameters.color = { 0, 1, 0 }\n buttonParameters.position.x = 1.5\n self.createButton(buttonParameters)\n\n -- update the display label once\n Wait.time(updateCount, 1)\nend\n\n---------------------------------------------------------\n-- events with descriptions\n---------------------------------------------------------\n\n-- dropping an object on the victory display\nfunction onCollisionEnter()\n startUpdate()\nend\n\n-- removing an object from the victory display\nfunction onCollisionExit()\n startUpdate()\nend\n\n-- picking a clue or location up\nfunction onObjectPickUp(_, obj)\n maybeUpdate(obj)\nend\n\n-- dropping a clue or location\nfunction onObjectDrop(_, obj)\n maybeUpdate(obj, 1)\nend\n\n-- flipping a clue/doom or location\nfunction onObjectRotate(obj, _, flip, _, _, oldFlip)\n if flip == oldFlip then return end\n maybeUpdate(obj, 1, true)\nend\n\n-- destroying a clue or location\nfunction onObjectDestroy(obj)\n maybeUpdate(obj)\nend\n\n---------------------------------------------------------\n-- main functionality\n---------------------------------------------------------\n\nfunction maybeUpdate(obj, delay, flipped)\n -- stop if there is already an update call running\n if pendingCall then return end\n\n -- stop if obj is nil (by e.g. dropping a clue onto another and making a stack)\n if obj == nil then return end\n\n -- only continue for clues / doom tokens or locations\n if obj.hasTag(\"Location\") then\n elseif obj.memo == \"clueDoom\" then\n -- only continue if the clue side is up or a doom token is being flipped\n if obj.is_face_down == true and flipped ~= true then return end\n else\n return\n end\n\n -- only continue if the obj in in the play area\n if not playAreaApi.isInPlayArea(obj) then return end\n\n startUpdate(delay)\nend\n\n-- starts an update\nfunction startUpdate(delay)\n -- stop if there is already an update call running\n if pendingCall then return end\n pendingCall = true\n delay = tonumber(delay) or 0\n Wait.time(updateCount, delay + 0.2)\nend\n\n-- counts the VP in the victory display and request the VP count from the play area\nfunction updateCount()\n missingData = {}\n countedVP = {}\n local victoryPoints = {}\n victoryPoints.display = 0\n victoryPoints.playArea = playAreaApi.countVP()\n\n -- count cards in victory display\n for _, obj in ipairs(searchLib.onObject(self, \"isCardOrDeck\")) do\n -- check metadata for VP\n if obj.type == \"Card\" then\n local VP = getCardVP(obj, JSON.decode(obj.getGMNotes()))\n victoryPoints.display = victoryPoints.display + VP\n if VP \u003e 0 then\n table.insert(countedVP, obj)\n end\n\n -- handling for stacked cards\n elseif obj.type == \"Deck\" then\n local VP = 0\n for _, deepObj in ipairs(obj.getObjects()) do\n local deepVP = getCardVP(obj, JSON.decode(deepObj.gm_notes))\n victoryPoints.display = victoryPoints.display + deepVP\n if deepVP \u003e 0 then\n VP = VP + 1\n end\n end\n if VP \u003e 0 then\n table.insert(countedVP, obj)\n end\n end\n end\n\n -- update the buttons that are used as labels\n self.editButton({ index = 0, label = victoryPoints.display })\n self.editButton({ index = 1, label = victoryPoints.playArea })\n self.editButton({ index = 2, label = victoryPoints.display + victoryPoints.playArea })\n\n -- allow new update calls\n pendingCall = false\nend\n\n-- gets the VP count from the notes\nfunction getCardVP(obj, notes)\n local cardVP\n if notes ~= nil then\n -- enemy, treachery etc.\n cardVP = tonumber(notes.victory)\n\n -- location\n if not cardVP then\n -- check the correct side of the location\n if not obj.is_face_down and notes.locationFront ~= nil then\n cardVP = tonumber(notes.locationFront.victory)\n elseif notes.locationBack ~= nil then\n cardVP = tonumber(notes.locationBack.victory)\n end\n end\n if (cardVP or 0) \u003e 0 then\n table.insert(countedVP, obj)\n end\n else\n table.insert(missingData, obj)\n end\n return cardVP or 0\nend\n\n-- toggles the highlight for objects with missing metadata\nfunction highlightMissingData()\n self.editButton({\n index = 3,\n tooltip = (highlightMissing and \"Enable\" or \"Disable\") .. \" highlighting of cards without metadata (VP on these is not counted).\" })\n for _, obj in pairs(missingData) do\n if obj ~= nil then\n if highlightMissing then\n obj.highlightOff(\"Red\")\n else\n obj.highlightOn(\"Red\")\n end\n end\n end\n playAreaApi.highlightMissingData(highlightMissing)\n highlightMissing = not highlightMissing\nend\n\n-- toggles the highlight for objects that were counted\nfunction highlightCountedVP()\n self.editButton({\n index = 4,\n tooltip = (highlightCounted and \"Enable\" or \"Disable\") .. \" highlighting of cards with VP.\"\n })\n for _, obj in pairs(countedVP) do\n if obj ~= nil then\n if highlightCounted then\n obj.highlightOff(\"Green\")\n else\n obj.highlightOn(\"Green\")\n end\n end\n end\n playAreaApi.highlightCountedVP(highlightCounted)\n highlightCounted = not highlightCounted\nend\n\n-- places the provided card in the first empty spot\nfunction placeCard(card)\n local trash = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"Trash\")\n\n -- check snap point states\n local snaps = self.getSnapPoints()\n table.sort(snaps, function(a, b) return a.position.x \u003e b.position.x end)\n table.sort(snaps, function(a, b) return a.position.z \u003c b.position.z end)\n\n -- get first empty slot\n local fullSlots = {}\n local positions = {}\n for i, snap in ipairs(snaps) do\n positions[i] = self.positionToWorld(snap.position)\n local searchResult = searchLib.atPosition(positions[i], \"isCardOrDeck\")\n fullSlots[i] = #searchResult \u003e 0\n end\n\n -- remove tokens from the card\n for _, obj in ipairs(searchLib.onObject(card)) do\n -- don't touch decks / cards\n if obj.type == \"Deck\" or obj.type == \"Card\" then\n -- put chaos tokens back into bag\n elseif tokenChecker.isChaosToken(obj) then\n local chaosBag = chaosBagApi.findChaosBag()\n chaosBag.putObject(obj)\n elseif obj.memo ~= nil and obj.getLock() == false then\n trash.putObject(obj)\n end\n end\n\n -- place the card\n local name = card.getName() or \"Unnamed card\"\n for i = 1, 10 do\n if fullSlots[i] ~= true then\n local rot = { 0, 270, card.getRotation().z }\n card.setPositionSmooth(positions[i], false, true)\n card.setRotation(rot)\n broadcastToAll(\"Victory Display: \" .. name .. \" placed into slot \" .. i .. \".\", \"Green\")\n return\n end\n end\n\n broadcastToAll(\"Victory Display is full! \" .. name .. \" placed into slot 1.\", \"Orange\")\n card.setPositionSmooth(positions[1], false, true)\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/token/TokenChecker\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local CHAOS_TOKEN_NAMES = {\n [\"Elder Sign\"] = true,\n [\"+1\"] = true,\n [\"0\"] = true,\n [\"-1\"] = true,\n [\"-2\"] = true,\n [\"-3\"] = true,\n [\"-4\"] = true,\n [\"-5\"] = true,\n [\"-6\"] = true,\n [\"-7\"] = true,\n [\"-8\"] = true,\n [\"Skull\"] = true,\n [\"Cultist\"] = true,\n [\"Tablet\"] = true,\n [\"Elder Thing\"] = true,\n [\"Auto-fail\"] = true,\n [\"Bless\"] = true,\n [\"Curse\"] = true,\n [\"Frost\"] = true\n }\n\n local TokenChecker = {}\n\n -- returns true if the passed object is a chaos token (by name)\n TokenChecker.isChaosToken = function(obj)\n if obj.type == \"Tile\" and CHAOS_TOKEN_NAMES[obj.getName()] then\n return true\n else\n return false\n end\n end\n\n return TokenChecker\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/VictoryDisplay\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Token", @@ -201260,33 +204420,90 @@ "Type": 0 }, "ImageScalar": 1, - "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2037357232933163412/1D2EE3BD0758463D8F6EB0DA30C59A21694BB1A4/", - "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2037357232933163412/1D2EE3BD0758463D8F6EB0DA30C59A21694BB1A4/", + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2460726979851338290/FD3A124A45AFAACAB85E34060B09B52FE798E991/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2460726979851337461/C6A08EA4A71B37F9C27E2545037F557D65BBF521/", "WidthScale": 0 }, "Description": "", "DragSelectable": true, "GMNotes": "", - "GUID": "e03c01", + "GUID": "8e22bb", "Grid": true, "GridProjection": false, "Hands": false, "HideWhenFaceDown": false, "IgnoreFoW": false, "LayoutGroupSortIndex": 0, - "Locked": true, + "Locked": false, "LuaScript": "", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Tile", - "Nickname": "Campaign Overview", + "Nickname": "Official Releases Overview", "Snap": true, "Sticky": true, "Tooltip": true, "Transform": { "posX": -1.6, "posY": 1.481, - "posZ": -58.5, + "posZ": -55, + "rotX": 0, + "rotY": 270, + "rotZ": 0, + "scaleX": 13, + "scaleY": 1, + "scaleZ": 13 + }, + "Value": 0, + "XmlUI": "" + }, + { + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 1, + "g": 1, + "r": 1 + }, + "CustomImage": { + "CustomTile": { + "Stackable": false, + "Stretch": true, + "Thickness": 0.1, + "Type": 0 + }, + "ImageScalar": 1, + "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/2460726979851342612/65DEC18BEFEFB1117CFEAAE9AB15B442AE8B557B/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2460726979851342006/859CF14CE18A4F8C2AFDADA3E69E1B6864154696/", + "WidthScale": 0 + }, + "Description": "", + "DragSelectable": true, + "GMNotes": "", + "GUID": "de7cae", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Tile", + "Nickname": "Fan-Made Expansion Overview", + "Snap": true, + "Sticky": true, + "Tooltip": true, + "Transform": { + "posX": -1.6, + "posY": 1.481, + "posZ": -75, "rotX": 0, "rotY": 270, "rotZ": 0, @@ -205025,7 +208242,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/SearchAssistant\")\nend)\n__bundle_register(\"accessories/SearchAssistant\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal searchLib = require(\"util/SearchLib\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- forward declaration of variables that are used across functions\nlocal matColor, handColor, setAsidePosition, setAsideRotation, drawDeckPosition, topCardDetected\n\nlocal quickParameters = {}\nquickParameters.function_owner = self\nquickParameters.font_size = 165\nquickParameters.width = 275\nquickParameters.height = 275\nquickParameters.color = \"White\"\n\n-- common parameters\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.font_size = 125\nbuttonParameters.width = 650\nbuttonParameters.height = 225\nbuttonParameters.color = \"White\"\n\nlocal inputParameters = {}\ninputParameters.function_owner = self\ninputParameters.input_function = \"updateSearchNumber\"\ninputParameters.tooltip = \"custom search amount\"\ninputParameters.label = \"#\"\ninputParameters.font_size = 175\ninputParameters.width = 400\ninputParameters.height = inputParameters.font_size + 23\ninputParameters.position = { 0, 0.11, 0 }\ninputParameters.alignment = 3\ninputParameters.validation = 2\n\nfunction onLoad()\n normalView()\nend\n\n-- regular view with search box\nfunction normalView()\n self.clearButtons()\n self.clearInputs()\n self.createInput(inputParameters)\n\n -- create custom search button\n buttonParameters.click_function = \"searchCustom\"\n buttonParameters.tooltip = \"Search the entered number of cards\"\n buttonParameters.position = { 0, 0.11, 0.65 }\n buttonParameters.label = \"Search\"\n self.createButton(buttonParameters)\n\n -- create buttons to search 3, 6 or 9 cards\n quickParameters.click_function = \"search3\"\n quickParameters.label = \"3\"\n quickParameters.position = { -0.65, 0.11, -0.65 }\n self.createButton(quickParameters)\n\n quickParameters.click_function = \"search6\"\n quickParameters.label = \"6\"\n quickParameters.position = { 0, 0.11, -0.65 }\n self.createButton(quickParameters)\n\n quickParameters.click_function = \"search9\"\n quickParameters.label = \"9\"\n quickParameters.position = { 0.65, 0.11, -0.65 }\n self.createButton(quickParameters)\nend\n\n-- click functions\nfunction search3(_, playerColor) startSearch(playerColor, 3) end\nfunction search6(_, playerColor) startSearch(playerColor, 6) end\nfunction search9(_, playerColor) startSearch(playerColor, 9) end\n\n-- view during a search with \"done\" buttons\nfunction searchView()\n self.clearButtons()\n self.clearInputs()\n\n -- create the \"End Search\" button\n buttonParameters.click_function = \"endSearch\"\n buttonParameters.tooltip = \"Left-click: Return cards and shuffle\\nRight-click: Return cards without shuffling\"\n buttonParameters.position = { 0, 0.11, 0 }\n buttonParameters.label = \"End Search\"\n self.createButton(buttonParameters)\nend\n\n-- input_function to get number of cards to search\nfunction updateSearchNumber(_, _, input)\n inputParameters.value = tonumber(input)\nend\n\n-- starts the search with the number from the input field\nfunction searchCustom(_, messageColor)\n local number = inputParameters.value\n if number ~= nil then\n startSearch(messageColor, number)\n else\n printToColor(\"Enter the number of cards to search in the textbox.\", messageColor, \"Orange\")\n end\nend\n\n-- start the search (change UI, set handCards aside, draw cards)\nfunction startSearch(messageColor, number)\n matColor = playmatApi.getMatColorByPosition(self.getPosition())\n handColor = playmatApi.getPlayerColor(matColor)\n topCardDetected = false\n\n -- get draw deck\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n if deckAreaObjects.draw == nil then\n printToColor(matColor .. \" draw deck could not be found!\", messageColor, \"Red\")\n return\n end\n\n -- get bounds to know the height of the deck\n local bounds = deckAreaObjects.draw.getBounds()\n drawDeckPosition = bounds.center + Vector(0, bounds.size.y / 2 + 0.2, 0)\n printToColor(\"Place target(s) of search on set aside hand.\", messageColor, \"Green\")\n\n -- get playmat orientation\n local offset = -15\n if matColor == \"Orange\" or matColor == \"Red\" then\n offset = 15\n end\n\n -- get position and rotation for set aside cards\n local handData = Player[handColor].getHandTransform()\n local handCards = Player[handColor].getHandObjects()\n setAsidePosition = handData.position + offset * handData.right\n setAsideRotation = { handData.rotation.x, handData.rotation.y + 180, 180 }\n\n -- set y-value\n setAsidePosition.y = 1.5\n\n for i = #handCards, 1, -1 do\n handCards[i].setPosition(setAsidePosition + Vector(0, (#handCards - i) * 0.1, 0))\n handCards[i].setRotation(setAsideRotation)\n end\n\n -- handling for Norman Withers\n if deckAreaObjects.topCard then\n deckAreaObjects.topCard.flip()\n topCardDetected = true\n end\n\n searchView()\n\n Wait.time(function()\n deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n deckAreaObjects.draw.deal(number, handColor)\n end, 1)\nend\n\n-- place handCards back into deck and optionally shuffle\nfunction endSearch(_, _, isRightClick)\n local handCards = Player[handColor].getHandObjects()\n\n for i = #handCards, 1, -1 do\n handCards[i].setPosition(drawDeckPosition + Vector(0, (#handCards - i) * 0.1, 0))\n handCards[i].setRotation(setAsideRotation)\n end\n\n -- draw set aside cards (from the ground!)\n for _, obj in ipairs(searchLib.atPosition(setAsidePosition, \"isCardOrDeck\")) do\n if obj.type == \"Deck\" then\n Wait.time(function() obj.deal(#obj.getObjects(), handColor) end, 1)\n elseif obj.type == \"Card\" then\n obj.setPosition(Player[handColor].getHandTransform().position)\n obj.flip()\n end\n end\n\n normalView()\n\n -- delay is to wait for cards to enter deck\n if not isRightClick then\n Wait.time(function()\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n if deckAreaObjects.draw then\n deckAreaObjects.draw.shuffle()\n end\n end, #handCards * 0.1)\n end\n\n -- Norman Withers handling\n if topCardDetected then\n Wait.time(function() playmatApi.flipTopCardFromDeck(matColor) end, #handCards * 0.1)\n end\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/SearchAssistant\")\nend)\n__bundle_register(\"accessories/SearchAssistant\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal searchLib = require(\"util/SearchLib\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- forward declaration of variables that are used across functions\nlocal matColor, handColor, setAsidePosition, setAsideRotation, drawDeckPosition, topCardDetected\n\nlocal quickParameters = {}\nquickParameters.function_owner = self\nquickParameters.font_size = 165\nquickParameters.width = 275\nquickParameters.height = 275\nquickParameters.color = \"White\"\n\n-- common parameters\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.font_size = 125\nbuttonParameters.width = 650\nbuttonParameters.height = 225\nbuttonParameters.color = \"White\"\n\nlocal inputParameters = {}\ninputParameters.function_owner = self\ninputParameters.input_function = \"updateSearchNumber\"\ninputParameters.tooltip = \"custom search amount\"\ninputParameters.label = \"#\"\ninputParameters.font_size = 175\ninputParameters.width = 400\ninputParameters.height = inputParameters.font_size + 23\ninputParameters.position = { 0, 0.11, 0 }\ninputParameters.alignment = 3\ninputParameters.validation = 2\n\nfunction onLoad()\n normalView()\nend\n\n-- regular view with search box\nfunction normalView()\n self.clearButtons()\n self.clearInputs()\n self.createInput(inputParameters)\n\n -- create custom search button\n buttonParameters.click_function = \"searchCustom\"\n buttonParameters.tooltip = \"Search the entered number of cards\"\n buttonParameters.position = { 0, 0.11, 0.65 }\n buttonParameters.label = \"Search\"\n self.createButton(buttonParameters)\n\n -- create buttons to search 3, 6 or 9 cards\n quickParameters.click_function = \"search3\"\n quickParameters.label = \"3\"\n quickParameters.position = { -0.65, 0.11, -0.65 }\n self.createButton(quickParameters)\n\n quickParameters.click_function = \"search6\"\n quickParameters.label = \"6\"\n quickParameters.position = { 0, 0.11, -0.65 }\n self.createButton(quickParameters)\n\n quickParameters.click_function = \"search9\"\n quickParameters.label = \"9\"\n quickParameters.position = { 0.65, 0.11, -0.65 }\n self.createButton(quickParameters)\nend\n\n-- click functions\nfunction search3(_, playerColor) startSearch(playerColor, 3) end\nfunction search6(_, playerColor) startSearch(playerColor, 6) end\nfunction search9(_, playerColor) startSearch(playerColor, 9) end\n\n-- view during a search with \"done\" buttons\nfunction searchView()\n self.clearButtons()\n self.clearInputs()\n\n -- create the \"End Search\" button\n buttonParameters.click_function = \"endSearch\"\n buttonParameters.tooltip = \"Left-click: Return cards and shuffle\\nRight-click: Return cards without shuffling\"\n buttonParameters.position = { 0, 0.11, 0 }\n buttonParameters.label = \"End Search\"\n self.createButton(buttonParameters)\nend\n\n-- input_function to get number of cards to search\nfunction updateSearchNumber(_, _, input)\n inputParameters.value = tonumber(input)\nend\n\n-- starts the search with the number from the input field\nfunction searchCustom(_, messageColor)\n local number = inputParameters.value\n if number ~= nil then\n startSearch(messageColor, number)\n else\n printToColor(\"Enter the number of cards to search in the textbox.\", messageColor, \"Orange\")\n end\nend\n\n-- start the search (change UI, set handCards aside, draw cards)\nfunction startSearch(messageColor, number)\n matColor = playmatApi.getMatColorByPosition(self.getPosition())\n handColor = playmatApi.getPlayerColor(matColor)\n topCardDetected = false\n\n -- get draw deck\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n if deckAreaObjects.draw == nil then\n printToColor(matColor .. \" draw deck could not be found!\", messageColor, \"Red\")\n return\n end\n\n -- get bounds to know the height of the deck\n local bounds = deckAreaObjects.draw.getBounds()\n drawDeckPosition = bounds.center + Vector(0, bounds.size.y / 2 + 0.2, 0)\n printToColor(\"Place target(s) of search on set aside hand.\", messageColor, \"Green\")\n\n -- get playmat orientation\n local offset = -15\n if matColor == \"Orange\" or matColor == \"Red\" then\n offset = 15\n end\n\n -- get position and rotation for set aside cards\n local handData = Player[handColor].getHandTransform()\n local handCards = Player[handColor].getHandObjects()\n setAsidePosition = handData.position + offset * handData.right\n setAsideRotation = { handData.rotation.x, handData.rotation.y + 180, 180 }\n\n -- set y-value\n setAsidePosition.y = 1.5\n\n for i = #handCards, 1, -1 do\n handCards[i].setPosition(setAsidePosition + Vector(0, (#handCards - i) * 0.1, 0))\n handCards[i].setRotation(setAsideRotation)\n end\n\n -- handling for Norman Withers\n if deckAreaObjects.topCard then\n deckAreaObjects.topCard.flip()\n topCardDetected = true\n end\n\n searchView()\n\n Wait.time(function()\n deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n deckAreaObjects.draw.deal(number, handColor)\n end, 1)\nend\n\n-- place handCards back into deck and optionally shuffle\nfunction endSearch(_, _, isRightClick)\n local handCards = Player[handColor].getHandObjects()\n\n for i = #handCards, 1, -1 do\n handCards[i].setPosition(drawDeckPosition + Vector(0, (#handCards - i) * 0.1, 0))\n handCards[i].setRotation(setAsideRotation)\n end\n\n -- draw set aside cards (from the ground!)\n for _, obj in ipairs(searchLib.atPosition(setAsidePosition, \"isCardOrDeck\")) do\n if obj.type == \"Deck\" then\n Wait.time(function() obj.deal(#obj.getObjects(), handColor) end, 1)\n elseif obj.type == \"Card\" then\n obj.setPosition(Player[handColor].getHandTransform().position)\n obj.flip()\n end\n end\n\n normalView()\n\n -- delay is to wait for cards to enter deck\n if not isRightClick then\n Wait.time(function()\n local deckAreaObjects = playmatApi.getDeckAreaObjects(matColor)\n if deckAreaObjects.draw then\n deckAreaObjects.draw.shuffle()\n end\n end, #handCards * 0.1)\n end\n\n -- Norman Withers handling\n if topCardDetected then\n Wait.time(function() playmatApi.flipTopCardFromDeck(matColor) end, #handCards * 0.1)\n end\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Tile", @@ -205086,7 +208303,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/HandHelper\")\nend)\n__bundle_register(\"accessories/HandHelper\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- forward declaration of variables that are used across functions\nlocal matColor, handColor, loopId, hovering\n\nfunction onLoad()\n local buttonParamaters = {}\n buttonParamaters.function_owner = self\n\n -- index 0: button as hand size label\n buttonParamaters.hover_color = \"White\"\n buttonParamaters.click_function = \"none\"\n buttonParamaters.position = { 0, 0.11, -0.4 }\n buttonParamaters.height = 0\n buttonParamaters.width = 0\n buttonParamaters.font_size = 500\n buttonParamaters.font_color = \"White\"\n self.createButton(buttonParamaters)\n\n -- index 1: button to toggle \"des\"\n buttonParamaters.label = \"DES: ✗\"\n buttonParamaters.click_function = \"none\"\n buttonParamaters.position = { 0, 0.11, 0.25 }\n buttonParamaters.height = 0\n buttonParamaters.width = 0\n buttonParamaters.font_size = 120\n self.createButton(buttonParamaters)\n\n -- index 2: button to discard a card\n buttonParamaters.label = \"discard random card\"\n buttonParamaters.click_function = \"discardRandom\"\n buttonParamaters.position = { 0, 0.11, 0.7 }\n buttonParamaters.height = 175\n buttonParamaters.width = 900\n buttonParamaters.font_size = 90\n buttonParamaters.font_color = \"Black\"\n self.createButton(buttonParamaters)\n\n updateColors()\n\n -- start loop to update card count\n loopId = Wait.time(updateValue, 1, -1)\nend\n\n-- updates colors when object is dropped somewhere\nfunction onDrop() updateColors() end\n\n-- toggles counting method briefly\nfunction onObjectHover(hover_color, obj)\n -- only continue if correct player hovers over \"self\"\n if obj ~= self or hover_color ~= handColor or hovering then return end\n\n -- toggle this flag so this doesn't get executed multiple times during the delay\n hovering = true\n\n -- stop loop, toggle \"des\" and displayed value briefly, then start new loop after 2s\n Wait.stop(loopId)\n updateValue(true)\n Wait.time(function()\n loopId = Wait.time(updateValue, 1, -1)\n hovering = false\n end, 1)\nend\n\n-- updates the matcolor and handcolor variable\nfunction updateColors()\n matColor = playmatApi.getMatColorByPosition(self.getPosition())\n handColor = playmatApi.getPlayerColor(matColor)\n self.setName(handColor .. \" Hand Helper\")\nend\n\n-- count cards in hand (by name for DES)\nfunction updateValue(toggle)\n -- update colors if handColor doesn't own a handzone\n if Player[handColor].getHandCount() == 0 then\n updateColors()\n end\n\n -- if there is still no handzone, then end here\n if Player[handColor].getHandCount() == 0 then return end\n\n -- get state of \"Dream-Enhancing Serum\" from playermat and update button label\n local des = playmatApi.isDES(matColor)\n if toggle then des = not des end\n self.editButton({ index = 1, label = \"DES: \" .. (des and \"✓\" or \"✗\") })\n\n -- count cards in hand\n local hand = Player[handColor].getHandObjects()\n local size = 0\n\n if des then\n local cardHash = {}\n for _, obj in pairs(hand) do\n if obj.tag == \"Card\" then\n local name = obj.getName()\n local title = string.match(name, '(.+)(%s%(%d+%))') or name\n cardHash[title] = true\n end\n end\n for _, title in pairs(cardHash) do\n size = size + 1\n end\n else\n for _, obj in pairs(hand) do\n if obj.tag == \"Card\" then size = size + 1 end\n end\n end\n\n -- update button label and color\n self.editButton({ index = 0, font_color = des and \"Green\" or \"White\", label = size })\nend\n\n-- discards a random non-hidden card from hand\nfunction discardRandom()\n playmatApi.doDiscardOne(matColor)\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"accessories/HandHelper\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- forward declaration of variables that are used across functions\nlocal matColor, handColor, loopId, hovering\n\nfunction onLoad()\n local buttonParamaters = {}\n buttonParamaters.function_owner = self\n\n -- index 0: button as hand size label\n buttonParamaters.hover_color = \"White\"\n buttonParamaters.click_function = \"none\"\n buttonParamaters.position = { 0, 0.11, -0.4 }\n buttonParamaters.height = 0\n buttonParamaters.width = 0\n buttonParamaters.font_size = 500\n buttonParamaters.font_color = \"White\"\n self.createButton(buttonParamaters)\n\n -- index 1: button to toggle \"des\"\n buttonParamaters.label = \"DES: ✗\"\n buttonParamaters.click_function = \"none\"\n buttonParamaters.position = { 0, 0.11, 0.25 }\n buttonParamaters.height = 0\n buttonParamaters.width = 0\n buttonParamaters.font_size = 120\n self.createButton(buttonParamaters)\n\n -- index 2: button to discard a card\n buttonParamaters.label = \"discard random card\"\n buttonParamaters.click_function = \"discardRandom\"\n buttonParamaters.position = { 0, 0.11, 0.7 }\n buttonParamaters.height = 175\n buttonParamaters.width = 900\n buttonParamaters.font_size = 90\n buttonParamaters.font_color = \"Black\"\n self.createButton(buttonParamaters)\n\n updateColors()\n\n -- start loop to update card count\n loopId = Wait.time(updateValue, 1, -1)\nend\n\n-- updates colors when object is dropped somewhere\nfunction onDrop() updateColors() end\n\n-- toggles counting method briefly\nfunction onObjectHover(hover_color, obj)\n -- only continue if correct player hovers over \"self\"\n if obj ~= self or hover_color ~= handColor or hovering then return end\n\n -- toggle this flag so this doesn't get executed multiple times during the delay\n hovering = true\n\n -- stop loop, toggle \"des\" and displayed value briefly, then start new loop after 2s\n Wait.stop(loopId)\n updateValue(true)\n Wait.time(function()\n loopId = Wait.time(updateValue, 1, -1)\n hovering = false\n end, 1)\nend\n\n-- updates the matcolor and handcolor variable\nfunction updateColors()\n matColor = playmatApi.getMatColorByPosition(self.getPosition())\n handColor = playmatApi.getPlayerColor(matColor)\n self.setName(handColor .. \" Hand Helper\")\nend\n\n-- count cards in hand (by name for DES)\nfunction updateValue(toggle)\n -- update colors if handColor doesn't own a handzone\n if Player[handColor].getHandCount() == 0 then\n updateColors()\n end\n\n -- if there is still no handzone, then end here\n if Player[handColor].getHandCount() == 0 then return end\n\n -- get state of \"Dream-Enhancing Serum\" from playermat and update button label\n local des = playmatApi.isDES(matColor)\n if toggle then des = not des end\n self.editButton({ index = 1, label = \"DES: \" .. (des and \"✓\" or \"✗\") })\n\n -- count cards in hand\n local hand = Player[handColor].getHandObjects()\n local size = 0\n\n if des then\n local cardHash = {}\n for _, obj in pairs(hand) do\n if obj.tag == \"Card\" then\n local name = obj.getName()\n local title = string.match(name, '(.+)(%s%(%d+%))') or name\n cardHash[title] = true\n end\n end\n for _, title in pairs(cardHash) do\n size = size + 1\n end\n else\n for _, obj in pairs(hand) do\n if obj.tag == \"Card\" then size = size + 1 end\n end\n end\n\n -- update button label and color\n self.editButton({ index = 0, font_color = des and \"Green\" or \"White\", label = size })\nend\n\n-- discards a random non-hidden card from hand\nfunction discardRandom()\n playmatApi.doDiscardOne(matColor)\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/HandHelper\")\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Tile", @@ -205147,7 +208364,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/DisplacementTool\")\nend)\n__bundle_register(\"accessories/DisplacementTool\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal playAreaApi = require(\"core/PlayAreaApi\")\n\nlocal UI_offset = 1.15\n\nlocal buttonParamaters = {}\nbuttonParamaters.function_owner = self\nbuttonParamaters.label = \"\"\nbuttonParamaters.height = 500\nbuttonParamaters.width = 500\nbuttonParamaters.color = { 0, 0, 0, 0 }\n\nfunction onLoad()\n -- index 0: left\n buttonParamaters.click_function = \"shift_left\"\n buttonParamaters.tooltip = \"Move left\"\n buttonParamaters.position = { -UI_offset, 0, 0 }\n self.createButton(buttonParamaters)\n\n -- index 1: right\n buttonParamaters.click_function = \"shift_right\"\n buttonParamaters.tooltip = \"Move right\"\n buttonParamaters.position = { UI_offset, 0, 0 }\n self.createButton(buttonParamaters)\n\n -- index 2: up\n buttonParamaters.click_function = \"shift_up\"\n buttonParamaters.tooltip = \"Move up\"\n buttonParamaters.position = { 0, 0, -UI_offset }\n self.createButton(buttonParamaters)\n\n -- index 3: down\n buttonParamaters.click_function = \"shift_down\"\n buttonParamaters.tooltip = \"Move down\"\n buttonParamaters.position = { 0, 0, UI_offset }\n self.createButton(buttonParamaters)\nend\n\nfunction shift_left(color) playAreaApi.shiftContentsLeft(color) end\n\nfunction shift_right(color) playAreaApi.shiftContentsRight(color) end\n\nfunction shift_up(color) playAreaApi.shiftContentsUp(color) end\n\nfunction shift_down(color) playAreaApi.shiftContentsDown(color) end\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/DisplacementTool\")\nend)\n__bundle_register(\"accessories/DisplacementTool\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal playAreaApi = require(\"core/PlayAreaApi\")\n\nlocal UI_offset = 1.15\n\nlocal buttonParamaters = {}\nbuttonParamaters.function_owner = self\nbuttonParamaters.label = \"\"\nbuttonParamaters.height = 500\nbuttonParamaters.width = 500\nbuttonParamaters.color = { 0, 0, 0, 0 }\n\nfunction onLoad()\n -- index 0: left\n buttonParamaters.click_function = \"shift_left\"\n buttonParamaters.tooltip = \"Move left\"\n buttonParamaters.position = { -UI_offset, 0, 0 }\n self.createButton(buttonParamaters)\n\n -- index 1: right\n buttonParamaters.click_function = \"shift_right\"\n buttonParamaters.tooltip = \"Move right\"\n buttonParamaters.position = { UI_offset, 0, 0 }\n self.createButton(buttonParamaters)\n\n -- index 2: up\n buttonParamaters.click_function = \"shift_up\"\n buttonParamaters.tooltip = \"Move up\"\n buttonParamaters.position = { 0, 0, -UI_offset }\n self.createButton(buttonParamaters)\n\n -- index 3: down\n buttonParamaters.click_function = \"shift_down\"\n buttonParamaters.tooltip = \"Move down\"\n buttonParamaters.position = { 0, 0, UI_offset }\n self.createButton(buttonParamaters)\nend\n\nfunction shift_left(color) playAreaApi.shiftContentsLeft(color) end\n\nfunction shift_right(color) playAreaApi.shiftContentsRight(color) end\n\nfunction shift_up(color) playAreaApi.shiftContentsUp(color) end\n\nfunction shift_down(color) playAreaApi.shiftContentsDown(color) end\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Token", @@ -205225,7 +208442,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/CleanUpHelper\")\nend)\n__bundle_register(\"accessories/CleanUpHelper\", function(require, _LOADED, __bundle_register, __bundle_modules)\n--[[ Cleans up the table for the next scenario in a campaign:\n- sets counters to default values (resources and doom) or trauma values (health and sanity, if not disabled) from campaign log\n- puts everything on playmats and hands into respective trashcans\n- use the IGNORE_TAG to exclude objects from tidying (default: \"CleanUpHelper_Ignore\")]]\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playAreaApi = require(\"core/PlayAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal soundCubeApi = require(\"core/SoundCubeApi\")\nlocal tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n-- objects with this tag will be ignored\nlocal IGNORE_TAG = \"CleanUpHelper_ignore\"\n\n-- colors and order for following tables\nlocal COLORS = { \"White\", \"Orange\", \"Green\", \"Red\", \"Mythos\" }\nlocal campaignLog\nlocal RESET_VALUES = {}\nlocal loadingFailedBefore = false\nlocal optionsVisible = false\n\nlocal options = {}\noptions[\"importTrauma\"] = true\noptions[\"tidyPlayermats\"] = true\noptions[\"removeDrawnLines\"] = false\n\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\n\n\n---------------------------------------------------------\n-- option loading and GUI setup\n---------------------------------------------------------\n\nfunction onSave()\n return JSON.encode({ options = options })\nend\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n local loadedData = JSON.decode(savedData)\n options = loadedData.options\n -- update UI to match saved state\n for id, state in pairs(options) do\n self.UI.setAttribute(id, \"image\", state and \"option_on\" or \"option_off\")\n end\n end\n\n -- index 0: button as label\n buttonParameters.label = \"Clean Up Helper\"\n buttonParameters.click_function = \"none\"\n buttonParameters.position = { x = 0, y = 0.1, z = -1.3 }\n buttonParameters.height = 0\n buttonParameters.width = 0\n buttonParameters.font_size = 230\n buttonParameters.font_color = Color(0, 0, 0)\n self.createButton(buttonParameters)\n\n -- index 1: option button\n buttonParameters.label = \"Settings\"\n buttonParameters.click_function = \"showOrHideOptions\"\n buttonParameters.color = { 0, 0, 0, 0.96 }\n buttonParameters.position.z = -0.1\n buttonParameters.height = 350\n buttonParameters.width = 1000\n buttonParameters.font_size = 190\n buttonParameters.font_color = \"White\"\n self.createButton(buttonParameters)\n\n -- index 2: start button\n buttonParameters.label = \"Reset play areas\"\n buttonParameters.click_function = \"cleanUp\"\n buttonParameters.position.z = 1.1\n buttonParameters.width = 1550\n self.createButton(buttonParameters)\nend\n\n---------------------------------------------------------\n-- click functions for option buttons\n---------------------------------------------------------\n\n-- changes the UI state and the internal variable for the togglebuttons\nfunction optionButtonClick(_, id)\n local currentState = options[id]\n local newState = (currentState and \"option_off\" or \"option_on\")\n options[id] = not currentState\n self.UI.setAttribute(id, \"image\", newState)\nend\n\n-- shows or hides the option panel\nfunction showOrHideOptions()\n optionsVisible = not optionsVisible\n\n if optionsVisible then\n self.UI.show(\"options\")\n else\n self.UI.hide(\"options\")\n end\nend\n\n---------------------------------------------------------\n-- main function\n---------------------------------------------------------\n\nfunction cleanUp(_, color)\n printToAll(\"------------------------------\", \"White\")\n printToAll(\"Clean up started!\", \"Orange\")\n printToAll(\"Resetting counters...\", \"White\")\n\n soundCubeApi.playSoundByName(\"Vacuum\")\n ignoreCustomDataHelper()\n getTrauma()\n\n -- delay to account for potential state change\n Wait.time(updateCounters, 0.2)\n\n resetDoomCounter()\n blessCurseManagerApi.removeAll(color)\n removeLines()\n discardHands()\n chaosBagApi.returnChaosTokens()\n chaosBagApi.releaseAllSealedTokens(color)\n\n printToAll(\"Tidying main play area...\", \"White\")\n startLuaCoroutine(self, \"tidyPlayareaCoroutine\")\nend\n\n---------------------------------------------------------\n-- modular functions, called by other functions\n---------------------------------------------------------\n\nfunction updateCounters()\n playmatApi.updateCounter(\"All\", \"ResourceCounter\" , 5)\n playmatApi.updateCounter(\"All\", \"ClickableClueCounter\" , 0)\n playmatApi.resetSkillTracker(\"All\")\n\n for i = 1, 4 do\n playmatApi.updateCounter(COLORS[i], \"DamageCounter\", RESET_VALUES.Damage[i])\n playmatApi.updateCounter(COLORS[i], \"HorrorCounter\", RESET_VALUES.Horror[i])\n end\nend\n\n-- reset doom on agenda\nfunction resetDoomCounter()\n local doomCounter = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DoomCounter\")\n if doomCounter ~= nil then\n doomCounter.call(\"updateVal\")\n else\n printToAll(\"Doom counter could not be found.\", \"Yellow\")\n end\nend\n\n-- adds the ignore tag to the custom data helper\nfunction ignoreCustomDataHelper()\n local customDataHelper = playAreaApi.getCustomDataHelper()\n if customDataHelper then\n customDataHelper.addTag(IGNORE_TAG)\n end\nend\n\n-- read values for trauma from campaign log if enabled\nfunction getTrauma()\n RESET_VALUES = {\n Damage = { 0, 0, 0, 0 },\n Horror = { 0, 0, 0, 0 }\n }\n\n -- stop here if trauma import is disabled\n if not options[\"importTrauma\"] then\n printToAll(\"Default values for health and sanity loaded.\", \"Yellow\")\n return\n end\n\n -- get campaign log\n campaignLog = getObjectsWithTag(\"CampaignLog\")[1]\n if campaignLog == nil then\n printToAll(\"Campaign log not found in standard position!\", \"Yellow\")\n printToAll(\"Default values for health and sanity loaded.\", \"Yellow\")\n return\n end\n loadTrauma()\nend\n\n-- gets data from campaign log if possible\nfunction loadTrauma()\n -- check if \"returnTrauma\" function exists to avoid calling nil\n local trauma = campaignLog.getVar(\"returnTrauma\")\n\n if trauma ~= nil then\n printToAll(\"Trauma values found in campaign log!\", \"Green\")\n trauma = campaignLog.call(\"returnTrauma\")\n for i = 1, 8 do\n if i \u003c 5 then\n RESET_VALUES.Damage[i] = trauma[i]\n else\n RESET_VALUES.Horror[i-4] = trauma[i]\n end\n end\n loadingFailedBefore = false\n elseif loadingFailedBefore then\n printToAll(\"Trauma values could not be found in campaign log!\", \"Yellow\")\n printToAll(\"Default values for health and sanity loaded.\", \"Yellow\")\n loadingFailedBefore = false\n else\n -- set campaign log to first state\n local stateId = campaignLog.getStateId()\n\n if stateId ~= 1 then\n campaignLog = campaignLog.setState(1)\n end\n loadingFailedBefore = true\n\n -- small delay to account for potential state change\n Wait.time(loadTrauma, 0.1)\n end\nend\n\n-- remove drawn lines\nfunction removeLines()\n if options[\"removeDrawnLines\"] then\n printToAll(\"Removing global vector lines...\", \"White\")\n Global.setVectorLines({})\n end\nend\n\n-- discard all hand objects\nfunction discardHands()\n if not options[\"tidyPlayermats\"] then return end\n for i = 1, 4 do\n local trash = guidReferenceApi.getObjectByOwnerAndType(COLORS[i], \"Trash\")\n if trash == nil then return end\n local hand = Player[playmatApi.getPlayerColor(COLORS[i])].getHandObjects()\n for j = #hand, 1, -1 do\n trash.putObject(hand[j])\n end\n end\nend\n\n-- clean up for play area\nfunction tidyPlayareaCoroutine()\n local trash = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"Trash\")\n local playAreaZone = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayAreaZone\")\n\n -- reset the playarea image by not providing an image\n playAreaApi.updateSurface()\n\n if playAreaZone == nil then\n printToAll(\"Scripting zone for main play area could not be found!\", \"Red\")\n elseif trash == nil then\n printToAll(\"Trashcan for main play area could not be found!\", \"Red\")\n else\n for _, obj in ipairs(playAreaZone.getObjects()) do\n -- ignore these elements\n if obj.hasTag(IGNORE_TAG) == false\n and obj.locked == false \n and obj.interactable == true then\n coroutine.yield(0)\n trash.putObject(obj)\n end\n end\n end\n\n printToAll(\"Tidying playermats and mythos area...\", \"White\")\n startLuaCoroutine(self, \"tidyPlayerMatCoroutine\")\n return 1\nend\n\n-- clean up for the four playermats and the mythos area\nfunction tidyPlayerMatCoroutine()\n for i = 1, 5 do\n -- only continue for playermat (1-4) if option enabled\n if options[\"tidyPlayermats\"] or i == 5 then\n -- delay for animation purpose\n for k = 1, 30 do coroutine.yield(0) end\n\n -- get respective trash\n local trash = guidReferenceApi.getObjectByOwnerAndType(COLORS[i], \"Trash\")\n if trash == nil then\n printToAll(\"Trashcan for \" .. COLORS[i] .. \" playmat could not be found!\", \"Red\")\n goto continue\n end\n\n local objList\n if i \u003c 5 then\n objList = playmatApi.searchAroundPlaymat(COLORS[i])\n else\n -- Victory Display + Mythos Area\n objList = searchLib.inArea({ -2, 2, 10 }, { 0, 270, 0 }, { 55, 1, 13.5 })\n end\n\n for _, obj in ipairs(objList) do\n -- ignore these elements\n if obj.hasTag(IGNORE_TAG) == false\n and obj.getDescription() ~= \"Action Token\"\n and obj.hasTag(\"chaosBag\") == false\n and obj.locked == false \n and obj.interactable == true then\n coroutine.yield(0)\n trash.putObject(obj)\n\n -- flip action tokens back to ready\n elseif obj.getDescription() == \"Action Token\" and obj.is_face_down then\n obj.flip()\n end\n end\n\n -- reset \"activeInvestigatorId\"\n if i \u003c 5 then\n local playermat = guidReferenceApi.getObjectByOwnerAndType(COLORS[i], \"Playermat\")\n if playermat then\n playermat.setVar(\"activeInvestigatorId\", \"00000\")\n end\n end\n end\n ::continue::\n end\n\n -- reset spawned data\n tokenSpawnTrackerApi.resetAll()\n local datahelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n if datahelper then\n datahelper.setTable(\"SPAWNED_PLAYER_CARD_GUIDS\", {})\n end\n\n printToAll(\"Clean up completed!\", \"Green\")\n return 1\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/SoundCubeApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SoundCubeApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- this table links the name of a trigger effect to its index\n local soundIndices = {\n [\"Vacuum\"] = 0,\n [\"Deep Bell\"] = 1,\n [\"Dark Souls\"] = 2\n }\n\n ---@param index number Index of the sound effect to play\n local function playTriggerEffect(index)\n local SoundCube = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"SoundCube\")\n SoundCube.AssetBundle.playTriggerEffect(index)\n end\n\n -- plays the by name requested sound\n ---@param soundName string Name of the sound to play\n SoundCubeApi.playSoundByName = function(soundName)\n playTriggerEffect(soundIndices[soundName])\n end\n\n return SoundCubeApi\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/CleanUpHelper\")\nend)\n__bundle_register(\"accessories/CleanUpHelper\", function(require, _LOADED, __bundle_register, __bundle_modules)\n-- Cleans up the table for the next scenario in a campaign:\n-- sets counters to default values (resources and doom) or trauma values (health and sanity, if not disabled) from campaign log\n-- puts everything on playmats and hands into respective trashcans\n-- use the IGNORE_TAG to exclude objects from tidying (default: \"CleanUpHelper_Ignore\")\n\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal playAreaApi = require(\"core/PlayAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal soundCubeApi = require(\"core/SoundCubeApi\")\nlocal tokenSpawnTrackerApi = require(\"core/token/TokenSpawnTrackerApi\")\n\n-- objects with this tag will be ignored\nlocal IGNORE_TAG = \"CleanUpHelper_ignore\"\n\n-- colors and order for following tables\nlocal COLORS = { \"White\", \"Orange\", \"Green\", \"Red\", \"Mythos\" }\nlocal campaignLog\nlocal RESET_VALUES = {}\nlocal loadingFailedBefore = false\nlocal optionsVisible = false\n\nlocal options = {}\noptions[\"importTrauma\"] = true\noptions[\"tidyPlayermats\"] = true\noptions[\"removeDrawnLines\"] = false\n\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\n\n---------------------------------------------------------\n-- option loading and GUI setup\n---------------------------------------------------------\n\nfunction onSave()\n return JSON.encode({ options = options })\nend\n\nfunction onLoad(savedData)\n if savedData ~= nil then\n local loadedData = JSON.decode(savedData)\n options = loadedData.options\n -- update UI to match saved state\n for id, state in pairs(options) do\n self.UI.setAttribute(id, \"image\", state and \"option_on\" or \"option_off\")\n end\n end\n\n -- index 0: button as label\n buttonParameters.label = \"Clean Up Helper\"\n buttonParameters.click_function = \"none\"\n buttonParameters.position = { x = 0, y = 0.1, z = -1.3 }\n buttonParameters.height = 0\n buttonParameters.width = 0\n buttonParameters.font_size = 230\n buttonParameters.font_color = Color(0, 0, 0)\n self.createButton(buttonParameters)\n\n -- index 1: option button\n buttonParameters.label = \"Settings\"\n buttonParameters.click_function = \"showOrHideOptions\"\n buttonParameters.color = { 0, 0, 0, 0.96 }\n buttonParameters.position.z = -0.1\n buttonParameters.height = 350\n buttonParameters.width = 1000\n buttonParameters.font_size = 190\n buttonParameters.font_color = \"White\"\n self.createButton(buttonParameters)\n\n -- index 2: start button\n buttonParameters.label = \"Reset play areas\"\n buttonParameters.click_function = \"cleanUp\"\n buttonParameters.position.z = 1.1\n buttonParameters.width = 1550\n self.createButton(buttonParameters)\nend\n\n---------------------------------------------------------\n-- click functions for option buttons\n---------------------------------------------------------\n\n-- changes the UI state and the internal variable for the togglebuttons\nfunction optionButtonClick(_, id)\n local currentState = options[id]\n local newState = (currentState and \"option_off\" or \"option_on\")\n options[id] = not currentState\n self.UI.setAttribute(id, \"image\", newState)\nend\n\n-- shows or hides the option panel\nfunction showOrHideOptions()\n optionsVisible = not optionsVisible\n\n if optionsVisible then\n self.UI.show(\"options\")\n else\n self.UI.hide(\"options\")\n end\nend\n\n---------------------------------------------------------\n-- main function\n---------------------------------------------------------\n\nfunction cleanUp(_, color)\n printToAll(\"------------------------------\", \"White\")\n printToAll(\"Clean up started!\", \"Orange\")\n printToAll(\"Resetting counters...\", \"White\")\n\n soundCubeApi.playSoundByName(\"Vacuum\")\n ignoreCustomDataHelper()\n getTrauma()\n\n -- delay to account for potential state change of campaign log\n Wait.time(updateCounters, 0.2)\n\n resetDoomCounter()\n blessCurseManagerApi.removeAll(color)\n removeLines()\n discardHands()\n chaosBagApi.returnChaosTokens()\n chaosBagApi.releaseAllSealedTokens(color)\n maybeIgnoreTekeliliCards()\n\n printToAll(\"Tidying main play area...\", \"White\")\n startLuaCoroutine(self, \"tidyPlayareaCoroutine\")\nend\n\n---------------------------------------------------------\n-- modular functions, called by other functions\n---------------------------------------------------------\n\nfunction updateCounters()\n playmatApi.updateCounter(\"All\", \"ResourceCounter\", 5)\n playmatApi.updateCounter(\"All\", \"ClickableClueCounter\", 0)\n playmatApi.resetSkillTracker(\"All\")\n\n for i = 1, 4 do\n playmatApi.updateCounter(COLORS[i], \"DamageCounter\", RESET_VALUES.Damage[i])\n playmatApi.updateCounter(COLORS[i], \"HorrorCounter\", RESET_VALUES.Horror[i])\n end\nend\n\n-- reset doom on agenda\nfunction resetDoomCounter()\n local doomCounter = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DoomCounter\")\n if doomCounter ~= nil then\n doomCounter.call(\"updateVal\")\n else\n printToAll(\"Doom counter could not be found.\", \"Yellow\")\n end\nend\n\n-- adds the ignore tag to the custom data helper\nfunction ignoreCustomDataHelper()\n local customDataHelper = playAreaApi.getCustomDataHelper()\n if customDataHelper then\n customDataHelper.addTag(IGNORE_TAG)\n end\nend\n\n-- read values for trauma from campaign log if enabled\nfunction getTrauma()\n RESET_VALUES = {\n Damage = { 0, 0, 0, 0 },\n Horror = { 0, 0, 0, 0 }\n }\n\n -- stop here if trauma import is disabled\n if not options[\"importTrauma\"] then\n printToAll(\"Default values for health and sanity loaded.\", \"Yellow\")\n return\n end\n\n -- get campaign log\n campaignLog = getObjectsWithTag(\"CampaignLog\")[1]\n if campaignLog == nil then\n printToAll(\"Campaign log not found in standard position!\", \"Yellow\")\n printToAll(\"Default values for health and sanity loaded.\", \"Yellow\")\n return\n end\n loadTrauma()\nend\n\n-- gets data from campaign log if possible\nfunction loadTrauma()\n -- check if \"returnTrauma\" function exists to avoid calling nil\n local trauma = campaignLog.getVar(\"returnTrauma\")\n\n if trauma ~= nil then\n printToAll(\"Trauma values found in campaign log!\", \"Green\")\n trauma = campaignLog.call(\"returnTrauma\")\n for i = 1, 8 do\n if i \u003c 5 then\n RESET_VALUES.Damage[i] = trauma[i]\n else\n RESET_VALUES.Horror[i - 4] = trauma[i]\n end\n end\n loadingFailedBefore = false\n elseif loadingFailedBefore then\n printToAll(\"Trauma values could not be found in campaign log!\", \"Yellow\")\n printToAll(\"Default values for health and sanity loaded.\", \"Yellow\")\n loadingFailedBefore = false\n else\n -- set campaign log to first state\n local stateId = campaignLog.getStateId()\n\n if stateId ~= 1 then\n campaignLog = campaignLog.setState(1)\n end\n loadingFailedBefore = true\n\n -- small delay to account for potential state change\n Wait.time(loadTrauma, 0.1)\n end\nend\n\n-- remove drawn lines\nfunction removeLines()\n if options[\"removeDrawnLines\"] then\n printToAll(\"Removing global vector lines...\", \"White\")\n Global.setVectorLines({})\n end\nend\n\n-- discard all hand objects\nfunction discardHands()\n if not options[\"tidyPlayermats\"] then return end\n for i = 1, 4 do\n local trash = guidReferenceApi.getObjectByOwnerAndType(COLORS[i], \"Trash\")\n if trash == nil then return end\n local hand = Player[playmatApi.getPlayerColor(COLORS[i])].getHandObjects()\n for j = #hand, 1, -1 do\n trash.putObject(hand[j])\n end\n end\nend\n\n-- maybe ignore cards / decks on the tekelili helper\nfunction maybeIgnoreTekeliliCards()\n local tekeliliHelper = getTekeliliHelper()\n\n if tekeliliHelper then\n local searchResult = searchLib.onObject(tekeliliHelper, \"isCardOrDeck\")\n for _, obj in ipairs(searchResult) do\n obj.addTag(IGNORE_TAG)\n end\n end\nend\n\n-- clean up for play area\nfunction tidyPlayareaCoroutine()\n local trash = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"Trash\")\n local playAreaZone = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayAreaZone\")\n\n -- reset the playarea image by not providing an image\n playAreaApi.updateSurface()\n\n if playAreaZone == nil then\n printToAll(\"Scripting zone for main play area could not be found!\", \"Red\")\n elseif trash == nil then\n printToAll(\"Trashcan for main play area could not be found!\", \"Red\")\n else\n for _, obj in ipairs(playAreaZone.getObjects()) do\n -- ignore these elements\n if obj.hasTag(IGNORE_TAG) == false\n and obj.locked == false\n and obj.interactable == true then\n coroutine.yield(0)\n trash.putObject(obj)\n end\n end\n end\n\n printToAll(\"Tidying playermats and mythos area...\", \"White\")\n startLuaCoroutine(self, \"tidyPlayerMatCoroutine\")\n return 1\nend\n\n-- clean up for the four playermats and the mythos area\nfunction tidyPlayerMatCoroutine()\n local tekeliliHelper = getTekeliliHelper()\n\n for i = 1, 5 do\n -- only continue for playermat (1-4) if option enabled\n if options[\"tidyPlayermats\"] or i == 5 then\n -- delay for animation purpose\n for k = 1, 30 do\n coroutine.yield(0)\n end\n\n -- get respective trash\n local trash = guidReferenceApi.getObjectByOwnerAndType(COLORS[i], \"Trash\")\n if trash == nil then\n printToAll(\"Trashcan for \" .. COLORS[i] .. \" playmat could not be found! Skipping this playermat.\", \"Yellow\")\n goto continue\n end\n\n -- maybe store tekelili cards\n if tekeliliHelper and i ~= 5 then\n tekeliliHelper.call(\"storeTekelili\", COLORS[i])\n end\n\n local objList\n if i \u003c 5 then\n objList = playmatApi.searchAroundPlaymat(COLORS[i])\n else\n -- Victory Display + Mythos Area\n objList = searchLib.inArea({ -2, 2, 10 }, { 0, 270, 0 }, { 55, 1, 13.5 })\n end\n\n for _, obj in ipairs(objList) do\n -- ignore these elements\n if obj.hasTag(IGNORE_TAG) == false\n and obj.getDescription() ~= \"Action Token\"\n and obj.hasTag(\"chaosBag\") == false\n and (obj.locked == false or obj.hasTag(\"Investigator\"))\n and obj.interactable == true then\n trash.putObject(obj)\n\n -- action token handling\n elseif obj.getDescription() == \"Action Token\" then\n -- move the small action token to the proper position\n if obj.getScale().x \u003c 0.4 then\n local pos = playmatApi.transformLocalPosition(Vector(-0.865, 0.1, -0.28), COLORS[i])\n obj.setPosition(pos)\n end\n\n -- flip action tokens back to ready\n if obj.is_face_down then\n local rot = playmatApi.returnRotation(COLORS[i])\n obj.setRotation(rot)\n end\n\n -- reset action token state\n local stateId = obj.getStateId()\n if stateId ~= -1 and stateId ~= 6 then\n coroutine.yield(0)\n obj.setState(6)\n end\n end\n end\n\n -- maybe respawn tekelili cards\n if tekeliliHelper and i ~= 5 then\n tekeliliHelper.call(\"spawnStoredTekelili\", COLORS[i])\n end\n end\n ::continue::\n end\n\n -- maybe remove ignore tag from cards / decks on the tekelili helper\n if tekeliliHelper then\n local searchResult = searchLib.onObject(tekeliliHelper, \"isCardOrDeck\")\n for _, obj in ipairs(searchResult) do\n obj.removeTag(IGNORE_TAG)\n end\n end\n\n -- reset \"activeInvestigatorId\"\n local playerMats = guidReferenceApi.getObjectsByType(\"Playermat\")\n for _, mat in pairs(playerMats) do\n mat.setVar(\"activeInvestigatorId\", \"00000\")\n end\n\n -- reset spawned data\n tokenSpawnTrackerApi.resetAll()\n local datahelper = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DataHelper\")\n if datahelper then\n datahelper.setTable(\"SPAWNED_PLAYER_CARD_GUIDS\", {})\n end\n\n printToAll(\"Clean up completed!\", \"Green\")\n return 1\nend\n\n-- used to detect the \"Tekeli-li Helper\" for Edge of the Earth\nfunction getTekeliliHelper()\n for _, obj in ipairs(getObjects()) do\n if obj.getName() == \"Tekeli-li Helper\" then\n return obj\n end\n end\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"core/SoundCubeApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SoundCubeApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n -- this table links the name of a trigger effect to its index\n local soundIndices = {\n [\"Vacuum\"] = 0,\n [\"Deep Bell\"] = 1,\n [\"Dark Souls\"] = 2\n }\n\n ---@param index number Index of the sound effect to play\n local function playTriggerEffect(index)\n local SoundCube = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"SoundCube\")\n SoundCube.AssetBundle.playTriggerEffect(index)\n end\n\n -- plays the by name requested sound\n ---@param soundName string Name of the sound to play\n SoundCubeApi.playSoundByName = function(soundName)\n playTriggerEffect(soundIndices[soundName])\n end\n\n return SoundCubeApi\nend\nend)\n__bundle_register(\"core/token/TokenSpawnTrackerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local TokenSpawnTracker = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getSpawnTracker()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TokenSpawnTracker\")\n end\n\n TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)\n return getSpawnTracker().call(\"hasSpawnedTokens\", cardGuid)\n end\n\n TokenSpawnTracker.markTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"markTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetTokensSpawned = function(cardGuid)\n return getSpawnTracker().call(\"resetTokensSpawned\", cardGuid)\n end\n\n TokenSpawnTracker.resetAllAssetAndEvents = function()\n return getSpawnTracker().call(\"resetAllAssetAndEvents\")\n end\n\n TokenSpawnTracker.resetAllLocations = function()\n return getSpawnTracker().call(\"resetAllLocations\")\n end\n\n TokenSpawnTracker.resetAll = function()\n return getSpawnTracker().call(\"resetAll\")\n end\n\n return TokenSpawnTracker\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "{\"options\":{\"importTrauma\":true,\"removeDrawnLines\":false,\"tidyPlayermats\":true}}", "MeasureMovement": false, "Name": "Custom_Token", @@ -205361,7 +208578,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GameKeyHandler\")\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/GameKeyHandler\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal navigationOverlayApi = require(\"core/NavigationOverlayApi\")\nlocal optionPanelApi = require(\"core/OptionPanelApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal victoryDisplayApi = require(\"core/VictoryDisplayApi\")\n\nfunction onLoad()\n addHotkey(\"Add doom to agenda\", addDoomToAgenda)\n addHotkey(\"Add Bless/Curse context menu\", addBlurseSealingMenu)\n addHotkey(\"Discard object\", discardObject)\n addHotkey(\"Discard top card\", discardTopDeck)\n addHotkey(\"Display Bless/Curse status\", showBlessCurseStatus)\n addHotkey(\"Move card to Victory Display\", moveCardToVictoryDisplay)\n addHotkey(\"Remove a use\", removeOneUse)\n addHotkey(\"Switch seat clockwise\", switchSeatClockwise)\n addHotkey(\"Switch seat counter-clockwise\", switchSeatCounterClockwise)\n addHotkey(\"Take clue from location\", takeClueFromLocation)\n addHotkey(\"Take clue from location (White)\", takeClueFromLocationWhite)\n addHotkey(\"Take clue from location (Orange)\", takeClueFromLocationOrange)\n addHotkey(\"Take clue from location (Green)\", takeClueFromLocationGreen)\n addHotkey(\"Take clue from location (Red)\", takeClueFromLocationRed)\n addHotkey(\"Upkeep\", triggerUpkeep)\n addHotkey(\"Upkeep (Multi-handed)\", triggerUpkeepMultihanded)\nend\n\n-- triggers the \"Upkeep\" function of the calling player's playmat\nfunction triggerUpkeep(playerColor)\n if playerColor == \"Black\" then\n broadcastToColor(\"Triggering 'Upkeep (Multihanded)' instead\", playerColor, \"Yellow\")\n triggerUpkeepMultihanded(playerColor)\n return\n end\n local matColor = playmatApi.getMatColor(playerColor)\n playmatApi.doUpkeepFromHotkey(matColor, playerColor)\nend\n\n-- triggers the \"Upkeep\" function of the calling player's playmat AND\n-- for all playmats that don't have a seated player, but a investigator card\nfunction triggerUpkeepMultihanded(playerColor)\n if playerColor ~= \"Black\" then\n triggerUpkeep(playerColor)\n end\n local colors = Player.getAvailableColors()\n for _, handColor in ipairs(colors) do\n local matColor = playmatApi.getMatColor(handColor)\n if playmatApi.returnInvestigatorId(matColor) ~= \"00000\" and Player[handColor].seated == false then\n playmatApi.doUpkeepFromHotkey(matColor, playerColor)\n end\n end\nend\n\n-- adds 1 doom to the agenda\nfunction addDoomToAgenda()\n local doomCounter = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DoomCounter\")\n doomCounter.call(\"addVal\", 1)\nend\n\n-- discard the hovered object to the respective trashcan and discard tokens on it if it was a card\nfunction discardObject(playerColor, hoveredObject)\n -- only continue if an unlocked card, deck or tile was hovered\n if hoveredObject == nil\n or (hoveredObject.type ~= \"Card\" and hoveredObject.type ~= \"Deck\" and hoveredObject.type ~= \"Tile\")\n or hoveredObject.locked then\n broadcastToColor(\"Hover a token/tile or a card/deck and try again.\", playerColor, \"Yellow\")\n return\n end\n\n -- warning for locations since these are usually not meant to be discarded\n if hoveredObject.hasTag(\"Location\") then\n broadcastToAll(\"Watch out: A location was discarded.\", \"Yellow\")\n end\n\n -- initialize list of objects to discard\n local discardTheseObjects = { hoveredObject }\n\n -- discard tokens / tiles on cards / decks\n if hoveredObject.type ~= \"Tile\" then\n for _, obj in ipairs(searchLib.onObject(hoveredObject, \"isTileOrToken\")) do\n table.insert(discardTheseObjects, obj)\n end\n end\n\n local discardForMatColor = getColorToDiscardFor(hoveredObject, playerColor)\n playmatApi.discardListOfObjects(discardForMatColor, discardTheseObjects)\nend\n\n-- discard the top card of hovered deck, calling discardObject function\nfunction discardTopDeck(playerColor, hoveredObject)\n -- only continue if an unlocked card or deck was hovered\n if hoveredObject == nil\n or (hoveredObject.type ~= \"Card\" and hoveredObject.type ~= \"Deck\")\n or hoveredObject.locked then\n broadcastToColor(\"Hover a deck/card and try again.\", playerColor, \"Yellow\")\n return\n end\n if hoveredObject.type == \"Deck\" then\n takenCard = hoveredObject.takeObject({index = 0})\n else\n takenCard = hoveredObject\n end\n Wait.frames(function() discardObject(playerColor, takenCard) end, 1)\nend \n\n-- helper function to get the player to trigger the discard function for\nfunction getColorToDiscardFor(hoveredObject, playerColor)\n local pos = hoveredObject.getPosition()\n local closestMatColor = playmatApi.getMatColorByPosition(pos)\n\n -- check if actually on the closest playmat\n local closestMat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local bounds = closestMat.getBounds()\n\n -- define the area \"near\" the playmat\n local bufferAroundPlaymat = 2\n local areaNearPlaymat = {}\n areaNearPlaymat.minX = bounds.center.x - bounds.size.x / 2 - bufferAroundPlaymat\n areaNearPlaymat.maxX = bounds.center.x + bounds.size.x / 2 + bufferAroundPlaymat\n areaNearPlaymat.minZ = bounds.center.z - bounds.size.z / 2 - bufferAroundPlaymat\n areaNearPlaymat.maxZ = bounds.center.z + bounds.size.z / 2 + bufferAroundPlaymat\n\n -- discard to closest mat if near it, use triggering playmat if not\n local discardForMatColor\n if inArea(pos, areaNearPlaymat) then\n return closestMatColor\n elseif pos.y \u003e (Player[playerColor].getHandTransform().position.y - (Player[playerColor].getHandTransform().scale.y / 2)) then -- discard to closest mat if card is in a hand\n return closestMatColor\n else\n return playmatApi.getMatColor(playerColor)\n end\nend\n\n-- moves the hovered card to the victory display\nfunction moveCardToVictoryDisplay(_, hoveredObject)\n victoryDisplayApi.placeCard(hoveredObject)\nend\n\n-- removes a use from a card (or a token if hovered)\nfunction removeOneUse(playerColor, hoveredObject)\n -- only continue if an unlocked card or tile was hovered\n if hoveredObject == nil\n or (hoveredObject.type ~= \"Card\" and hoveredObject.type ~= \"Tile\")\n or hoveredObject.locked then\n broadcastToColor(\"Hover a token/tile or a card and try again.\", playerColor, \"Yellow\")\n return\n end\n\n local targetObject = nil\n\n -- discard hovered token / tile\n if hoveredObject.type == \"Tile\" then\n targetObject = hoveredObject\n elseif hoveredObject.type == \"Card\" then\n -- grab the first use type from the metadata (or nil)\n local notes = JSON.decode(hoveredObject.getGMNotes()) or {}\n local usesData = notes.uses or {}\n local useInfo = usesData[1] or {}\n local searchForType = useInfo.type\n if searchForType then searchForType = searchForType:lower() end\n\n for _, obj in ipairs(searchLib.onObject(hoveredObject, \"isTileOrToken\")) do\n if not obj.locked and obj.memo ~= \"resourceCounter\" then\n -- check for matching object, otherwise use the first hit\n if obj.memo == searchForType then\n targetObject = obj\n break\n elseif not targetObject then\n targetObject = obj\n end\n end\n end\n end\n\n -- error handling\n if not targetObject then\n broadcastToColor(\"No tokens found!\", playerColor, \"Yellow\")\n return\n end\n\n -- handling for stacked tokens\n if targetObject.getQuantity() \u003e 1 then\n targetObject = targetObject.takeObject()\n end\n\n -- feedback message\n local tokenName = targetObject.getName()\n if tokenName == \"\" then\n if targetObject.memo ~= \"\" then\n -- name handling for clue / doom\n if targetObject.memo == \"clueDoom\" then\n if targetObject.is_face_down then\n tokenName = \"Doom\"\n else\n tokenName = \"Clue\"\n end\n else\n tokenName = titleCase(targetObject.memo)\n end\n else\n tokenName = \"Unknown\"\n end\n end\n\n local playerName = Player[playerColor].steam_name\n broadcastToAll(playerName .. \" removed a token: \" .. tokenName, playerColor)\n\n local discardForMatColor = getColorToDiscardFor(hoveredObject, playerColor)\n playmatApi.discardListOfObjects(discardForMatColor, { targetObject })\nend\n\n-- switches the triggering player to the next seat (clockwise)\nfunction switchSeatClockwise(playerColor)\n switchSeat(playerColor, \"clockwise\")\nend\n\n-- switches the triggering player to the next seat (counter-clockwise)\nfunction switchSeatCounterClockwise(playerColor)\n switchSeat(playerColor, \"counter-clockwise\")\nend\n\n-- handles seat switching in the given direction\nfunction switchSeat(playerColor, direction)\n if playerColor == \"Black\" or playerColor == \"Grey\" then\n broadcastToColor(\"This hotkey is only available to seated players.\", playerColor, \"Orange\")\n return\n end\n\n -- sort function for matcolors based on hand position (Green, White, Orange, Red)\n local function sortByHandPosition(color1, color2)\n local pos1 = Player[color1].getHandTransform().position\n local pos2 = Player[color2].getHandTransform().position\n return pos1.z \u003e pos2.z\n end\n\n -- get used playermats\n local usedColors = playmatApi.getUsedMatColors()\n table.sort(usedColors, sortByHandPosition)\n\n -- get current seat index\n local index\n for i, color in ipairs(usedColors) do\n if color == playerColor then\n index = i\n break\n end\n end\n if not index then\n broadcastToColor(\"Couldn't detect investigator.\", playerColor, \"Orange\")\n return\n end\n\n -- get next color\n index = index + ((direction == \"clockwise\") and -1 or 1)\n if index == 0 then\n index = #usedColors\n elseif index \u003e #usedColors then\n index = 1\n end\n\n -- swap color\n navigationOverlayApi.loadCamera(Player[playerColor], usedColors[index])\nend\n\nfunction takeClueFromLocationWhite(_, hoveredObject)\n takeClueFromLocation(\"White\", hoveredObject)\nend\n\nfunction takeClueFromLocationOrange(_, hoveredObject)\n takeClueFromLocation(\"Orange\", hoveredObject)\nend\n\nfunction takeClueFromLocationGreen(_, hoveredObject)\n takeClueFromLocation(\"Green\", hoveredObject)\nend\n\nfunction takeClueFromLocationRed(_, hoveredObject)\n takeClueFromLocation(\"Red\", hoveredObject)\nend\n\n-- takes a clue from a location, player needs to hover the clue directly or the location\nfunction takeClueFromLocation(playerColor, hoveredObject)\n local cardName, clue\n\n if hoveredObject == nil then\n broadcastToColor(\"Hover a clue or card with clues and try again.\", playerColor, \"Yellow\")\n return\n elseif hoveredObject.type == \"Card\" then\n cardName = hoveredObject.getName()\n local searchResult = searchLib.onObject(hoveredObject, \"isClue\")\n\n if #searchResult == 0 then\n broadcastToColor(\"This card does not have any clues on it.\", playerColor, \"Yellow\")\n return\n else\n clue = searchResult[1]\n end\n elseif hoveredObject.memo == \"clueDoom\" then\n if hoveredObject.is_face_down then\n broadcastToColor(\"This is a doom token and not a clue.\", playerColor, \"Yellow\")\n return\n end\n\n clue = hoveredObject\n local searchResult = searchLib.belowPosition(clue.getPosition(), \"isCard\")\n\n if #searchResult ~= 0 then\n cardName = searchResult[1].getName()\n end\n elseif hoveredObject.type == \"Infinite\" and hoveredObject.getName() == \"Clue tokens\" then\n clue = hoveredObject.takeObject()\n cardName = \"token pool\"\n else\n broadcastToColor(\"Hover a clue or card with clues and try again.\", playerColor, \"Yellow\")\n return\n end\n\n local clickableClues = optionPanelApi.getOptions()[\"useClueClickers\"]\n local playerName = Player[playerColor].steam_name\n local matColor = playmatApi.getMatColor(playerColor)\n local pos = nil\n if clickableClues then\n pos = {x = 0.49, y = 2.66, z = 0.00}\n playmatApi.updateCounter(matColor, \"ClickableClueCounter\", _, 1)\n else\n pos = playmatApi.transformLocalPosition({x = -1.12, y = 0.05, z = 0.7}, matColor)\n end\n \n local rot = playmatApi.returnRotation(matColor)\n\n -- check if found clue is a stack or single token\n if clue.getQuantity() \u003e 1 then\n clue.takeObject({position = pos, rotation = rot})\n else\n clue.setPositionSmooth(pos)\n clue.setRotation(rot)\n end\n\n if cardName then\n broadcastToAll(playerName .. \" took one clue from \" .. cardName .. \".\", \"White\")\n else\n broadcastToAll(playerName .. \" took one clue.\", \"White\")\n end\n\n victoryDisplayApi.update()\nend\n\n-- broadcasts the bless/curse status to the calling player\nfunction showBlessCurseStatus(playerColor)\n blessCurseManagerApi.broadcastStatus(playerColor)\nend\n\n-- adds Wendy's menu to the hovered card\nfunction addBlurseSealingMenu(playerColor, hoveredObject)\n blessCurseManagerApi.addBlurseSealingMenu(playerColor, hoveredObject)\nend\n\n-- Simple method to check if the given point is in a specified area\n---@param point tts__Vector Point to check, only x and z values are relevant\n---@param bounds table Defined area to see if the point is within\nfunction inArea(point, bounds)\n return (point.x \u003e bounds.minX\n and point.x \u003c bounds.maxX\n and point.z \u003e bounds.minZ\n and point.z \u003c bounds.maxZ)\nend\n\n-- capitalizes the first letter\nfunction titleCase(str)\n local first = str:sub(1, 1)\n local rest = str:sub(2)\n return first:upper() .. rest:lower()\nend\nend)\n__bundle_register(\"core/NavigationOverlayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local NavigationOverlayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getNOHandler()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"NavigationOverlayHandler\")\n end\n\n -- copies the visibility for the Navigation overlay\n ---@param startColor string Color of the player to copy from\n ---@param targetColor string Color of the targeted player\n NavigationOverlayApi.copyVisibility = function(startColor, targetColor)\n getNOHandler().call(\"copyVisibility\", {\n startColor = startColor,\n targetColor = targetColor\n })\n end\n\n -- changes the Navigation Overlay view (\"Full View\" --\u003e \"Play Areas\" --\u003e \"Closed\" etc.)\n ---@param playerColor string Color of the player to update the visibility for\n NavigationOverlayApi.cycleVisibility = function(playerColor)\n getNOHandler().call(\"cycleVisibility\", playerColor)\n end\n\n -- loads the specified camera for a player\n ---@param player tts__Player Player whose camera should be moved\n ---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to\n NavigationOverlayApi.loadCamera = function(player, camera)\n getNOHandler().call(\"loadCameraFromApi\", {\n player = player,\n camera = camera\n })\n end\n\n return NavigationOverlayApi\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/VictoryDisplayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local VictoryDisplayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getVictoryDisplay()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"VictoryDisplay\")\n end\n\n -- triggers an update of the victory count\n ---@param delay? number Delay in seconds after which the update call is executed\n VictoryDisplayApi.update = function(delay)\n getVictoryDisplay().call(\"startUpdate\", delay)\n end\n\n -- moves a card to the victory display (in the first empty spot)\n ---@param object tts__Object Object that should be checked and potentially moved\n VictoryDisplayApi.placeCard = function(object)\n if object ~= nil and object.tag == \"Card\" then\n getVictoryDisplay().call(\"placeCard\", object)\n end\n end\n\n return VictoryDisplayApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/GameKeyHandler\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal blessCurseManagerApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal navigationOverlayApi = require(\"core/NavigationOverlayApi\")\nlocal optionPanelApi = require(\"core/OptionPanelApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\nlocal searchLib = require(\"util/SearchLib\")\nlocal victoryDisplayApi = require(\"core/VictoryDisplayApi\")\n\nfunction onLoad()\n addHotkey(\"Add doom to agenda\", addDoomToAgenda)\n addHotkey(\"Add Bless/Curse context menu\", addBlurseSealingMenu)\n addHotkey(\"Discard object\", discardObject)\n addHotkey(\"Discard top card\", discardTopDeck)\n addHotkey(\"Display Bless/Curse status\", showBlessCurseStatus)\n addHotkey(\"Move card to Victory Display\", moveCardToVictoryDisplay)\n addHotkey(\"Place card into threat area\", takeCardIntoThreatArea)\n addHotkey(\"Remove a use\", removeOneUse)\n addHotkey(\"Switch seat clockwise\", switchSeatClockwise)\n addHotkey(\"Switch seat counter-clockwise\", switchSeatCounterClockwise)\n addHotkey(\"Take clue from location\", takeClueFromLocation)\n addHotkey(\"Take clue from location (White)\", takeClueFromLocationWhite)\n addHotkey(\"Take clue from location (Orange)\", takeClueFromLocationOrange)\n addHotkey(\"Take clue from location (Green)\", takeClueFromLocationGreen)\n addHotkey(\"Take clue from location (Red)\", takeClueFromLocationRed)\n addHotkey(\"Upkeep\", triggerUpkeep)\n addHotkey(\"Upkeep (Multi-handed)\", triggerUpkeepMultihanded)\nend\n\n-- triggers the \"Upkeep\" function of the calling player's playmat\nfunction triggerUpkeep(playerColor)\n if playerColor == \"Black\" then\n broadcastToColor(\"Triggering 'Upkeep (Multihanded)' instead\", playerColor, \"Yellow\")\n triggerUpkeepMultihanded(playerColor)\n return\n end\n local matColor = playmatApi.getMatColor(playerColor)\n playmatApi.doUpkeepFromHotkey(matColor, playerColor)\nend\n\n-- triggers the \"Upkeep\" function of the calling player's playmat AND\n-- for all playmats that don't have a seated player, but an investigator card\nfunction triggerUpkeepMultihanded(playerColor)\n if playerColor ~= \"Black\" then\n triggerUpkeep(playerColor)\n end\n local colors = Player.getAvailableColors()\n for _, handColor in ipairs(colors) do\n local matColor = playmatApi.getMatColor(handColor)\n if playmatApi.returnInvestigatorId(matColor) ~= \"00000\" and Player[handColor].seated == false then\n playmatApi.doUpkeepFromHotkey(matColor, playerColor)\n end\n end\nend\n\n-- adds 1 doom to the agenda\nfunction addDoomToAgenda()\n local doomCounter = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DoomCounter\")\n doomCounter.call(\"addVal\", 1)\nend\n\n-- move the hovered object to the nearest empty slot on the playermat\nfunction takeCardIntoThreatArea(playerColor, hoveredObject)\n -- only continue if an unlocked card\n if hoveredObject == nil\n or hoveredObject.type ~= \"Card\" and hoveredObject.type ~= \"Deck\"\n or hoveredObject.hasTag(\"Location\")\n or hoveredObject.locked then\n broadcastToColor(\"Hover a non-location card and try again.\", playerColor, \"Yellow\")\n return\n end\n\n local matColor = playmatApi.getMatColor(playerColor)\n local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\")\n -- do not continue if the threat area is already full\n if playmatApi.getEncounterCardDrawPosition(matColor, false) == playmatApi.getEncounterCardDrawPosition(matColor, true) then \n broadcastToColor(\"Threat area is full.\", playerColor,\"Yellow\")\n return \n end\n \n \n -- initialize list of objects to move\n local moveTheseObjects = {}\n \n for _, obj in ipairs(searchLib.onObject(hoveredObject, \"isTileOrToken\")) do\n table.insert(moveTheseObjects, obj)\n end\n \n -- find out if the original card is on the green or red playmats\n local originalMatColor = guidReferenceApi.getOwnerOfObject(hoveredObject)\n \n -- determine modifiers for the playmats\n local modifierY\n if originalMatColor == \"Red\" then\n modifierY = 90\n elseif originalMatColor == \"Green\" then\n modifierY = -90\n else\n modifierY = 0\n end\n\n local localPositions = {}\n\n for i, obj in ipairs(moveTheseObjects) do\n local localPos = hoveredObject.positionToLocal(obj.getPosition())\n localPositions[i] = localPos\n end\n \n -- move the main card\n local pos = playmatApi.getEncounterCardDrawPosition(matColor, false)\n hoveredObject.setPosition(pos)\n hoveredObject.setRotation(hoveredObject.getRotation() - Vector(0, 270-mat.getRotation().y-modifierY, 0))\n \n local cardName = hoveredObject.getName()\n if cardName == nil or cardName == \"\" then\n cardName = \"card(s)\"\n end\n broadcastToAll(\"Placed \" .. cardName .. \" into threat area.\", \"White\")\n\n for i, obj in ipairs(moveTheseObjects) do\n if not obj.locked then\n local globalPos = hoveredObject.positionToWorld(localPositions[i])\n obj.setPosition(globalPos)\n obj.setRotation(obj.getRotation() - Vector(0, 270-mat.getRotation().y-modifierY, 0))\n end\n end\nend\n\n-- discard the hovered object to the respective trashcan and discard tokens on it if it was a card\nfunction discardObject(playerColor, hoveredObject)\n -- only continue if an unlocked card, deck or tile was hovered\n if hoveredObject == nil\n or (hoveredObject.type ~= \"Card\" and hoveredObject.type ~= \"Deck\" and hoveredObject.type ~= \"Tile\")\n or hoveredObject.locked then\n broadcastToColor(\"Hover a token/tile or a card/deck and try again.\", playerColor, \"Yellow\")\n return\n end\n\n -- warning for locations since these are usually not meant to be discarded\n if hoveredObject.hasTag(\"Location\") then\n broadcastToAll(\"Watch out: A location was discarded.\", \"Yellow\")\n end\n\n -- initialize list of objects to discard\n local discardTheseObjects = { hoveredObject }\n\n -- discard tokens / tiles on cards / decks\n if hoveredObject.type ~= \"Tile\" then\n for _, obj in ipairs(searchLib.onObject(hoveredObject, \"isTileOrToken\")) do\n table.insert(discardTheseObjects, obj)\n end\n end\n\n local discardForMatColor = getColorToDiscardFor(hoveredObject, playerColor)\n playmatApi.discardListOfObjects(discardForMatColor, discardTheseObjects)\nend\n\n-- discard the top card of hovered deck, calling discardObject function\nfunction discardTopDeck(playerColor, hoveredObject)\n -- only continue if an unlocked card or deck was hovered\n if hoveredObject == nil\n or (hoveredObject.type ~= \"Card\" and hoveredObject.type ~= \"Deck\")\n or hoveredObject.locked then\n broadcastToColor(\"Hover a deck/card and try again.\", playerColor, \"Yellow\")\n return\n end\n if hoveredObject.type == \"Deck\" then\n takenCard = hoveredObject.takeObject({index = 0})\n else\n takenCard = hoveredObject\n end\n Wait.frames(function() discardObject(playerColor, takenCard) end, 1)\nend \n\n-- helper function to get the player to trigger the discard function for\nfunction getColorToDiscardFor(hoveredObject, playerColor)\n local pos = hoveredObject.getPosition()\n local closestMatColor = playmatApi.getMatColorByPosition(pos)\n\n -- check if actually on the closest playmat\n local closestMat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, \"Playermat\")\n local bounds = closestMat.getBounds()\n\n -- define the area \"near\" the playmat\n local bufferAroundPlaymat = 2\n local areaNearPlaymat = {}\n areaNearPlaymat.minX = bounds.center.x - bounds.size.x / 2 - bufferAroundPlaymat\n areaNearPlaymat.maxX = bounds.center.x + bounds.size.x / 2 + bufferAroundPlaymat\n areaNearPlaymat.minZ = bounds.center.z - bounds.size.z / 2 - bufferAroundPlaymat\n areaNearPlaymat.maxZ = bounds.center.z + bounds.size.z / 2 + bufferAroundPlaymat\n\n -- discard to closest mat if near it, use triggering playmat if not\n local discardForMatColor\n if inArea(pos, areaNearPlaymat) then\n return closestMatColor\n elseif pos.y \u003e (Player[playerColor].getHandTransform().position.y - (Player[playerColor].getHandTransform().scale.y / 2)) then -- discard to closest mat if card is in a hand\n return closestMatColor\n else\n return playmatApi.getMatColor(playerColor)\n end\nend\n\n-- moves the hovered card to the victory display\nfunction moveCardToVictoryDisplay(_, hoveredObject)\n victoryDisplayApi.placeCard(hoveredObject)\nend\n\n-- removes a use from a card (or a token if hovered)\nfunction removeOneUse(playerColor, hoveredObject)\n -- only continue if an unlocked card or tile was hovered\n if hoveredObject == nil\n or (hoveredObject.type ~= \"Card\" and hoveredObject.type ~= \"Tile\")\n or hoveredObject.locked then\n broadcastToColor(\"Hover a token/tile or a card and try again.\", playerColor, \"Yellow\")\n return\n end\n\n local targetObject = nil\n\n -- discard hovered token / tile\n if hoveredObject.type == \"Tile\" then\n targetObject = hoveredObject\n elseif hoveredObject.type == \"Card\" then\n -- grab the first use type from the metadata (or nil)\n local notes = JSON.decode(hoveredObject.getGMNotes()) or {}\n local usesData = notes.uses or {}\n local useInfo = usesData[1] or {}\n local searchForType = useInfo.type\n if searchForType then searchForType = searchForType:lower() end\n\n for _, obj in ipairs(searchLib.onObject(hoveredObject, \"isTileOrToken\")) do\n if not obj.locked and obj.memo ~= \"resourceCounter\" then\n -- check for matching object, otherwise use the first hit\n if obj.memo == searchForType then\n targetObject = obj\n break\n elseif not targetObject then\n targetObject = obj\n end\n end\n end\n end\n\n -- error handling\n if not targetObject then\n broadcastToColor(\"No tokens found!\", playerColor, \"Yellow\")\n return\n end\n\n -- handling for stacked tokens\n if targetObject.getQuantity() \u003e 1 then\n targetObject = targetObject.takeObject()\n end\n\n -- feedback message\n local tokenName = targetObject.getName()\n if tokenName == \"\" then\n if targetObject.memo ~= \"\" then\n -- name handling for clue / doom\n if targetObject.memo == \"clueDoom\" then\n if targetObject.is_face_down then\n tokenName = \"Doom\"\n else\n tokenName = \"Clue\"\n end\n else\n tokenName = titleCase(targetObject.memo)\n end\n else\n tokenName = \"Unknown\"\n end\n end\n\n local playerName = Player[playerColor].steam_name\n broadcastToAll(playerName .. \" removed a token: \" .. tokenName, playerColor)\n\n local discardForMatColor = getColorToDiscardFor(hoveredObject, playerColor)\n playmatApi.discardListOfObjects(discardForMatColor, { targetObject })\nend\n\n-- switches the triggering player to the next seat (clockwise)\nfunction switchSeatClockwise(playerColor)\n switchSeat(playerColor, \"clockwise\")\nend\n\n-- switches the triggering player to the next seat (counter-clockwise)\nfunction switchSeatCounterClockwise(playerColor)\n switchSeat(playerColor, \"counter-clockwise\")\nend\n\n-- handles seat switching in the given direction\nfunction switchSeat(playerColor, direction)\n if playerColor == \"Black\" or playerColor == \"Grey\" then\n broadcastToColor(\"This hotkey is only available to seated players.\", playerColor, \"Orange\")\n return\n end\n\n -- sort function for matcolors based on hand position (Green, White, Orange, Red)\n local function sortByHandPosition(color1, color2)\n local pos1 = Player[color1].getHandTransform().position\n local pos2 = Player[color2].getHandTransform().position\n return pos1.z \u003e pos2.z\n end\n\n -- get used playermats\n local usedColors = playmatApi.getUsedMatColors()\n table.sort(usedColors, sortByHandPosition)\n\n -- get current seat index\n local index\n for i, color in ipairs(usedColors) do\n if color == playerColor then\n index = i\n break\n end\n end\n if not index then\n broadcastToColor(\"Couldn't detect investigator.\", playerColor, \"Orange\")\n return\n end\n\n -- get next color\n index = index + ((direction == \"clockwise\") and -1 or 1)\n if index == 0 then\n index = #usedColors\n elseif index \u003e #usedColors then\n index = 1\n end\n\n -- swap color\n navigationOverlayApi.loadCamera(Player[playerColor], usedColors[index])\nend\n\nfunction takeClueFromLocationWhite(_, hoveredObject)\n takeClueFromLocation(\"White\", hoveredObject)\nend\n\nfunction takeClueFromLocationOrange(_, hoveredObject)\n takeClueFromLocation(\"Orange\", hoveredObject)\nend\n\nfunction takeClueFromLocationGreen(_, hoveredObject)\n takeClueFromLocation(\"Green\", hoveredObject)\nend\n\nfunction takeClueFromLocationRed(_, hoveredObject)\n takeClueFromLocation(\"Red\", hoveredObject)\nend\n\n-- takes a clue from a location, player needs to hover the clue directly or the location\nfunction takeClueFromLocation(playerColor, hoveredObject)\n -- use different color for messages if player is not seated (because this hotkey is called for a different mat)\n local messageColor = playerColor\n if not Player[playerColor] or not Player[playerColor].seated then\n messageColor = getFirstSeatedPlayer()\n end\n\n local cardName, clue\n\n if hoveredObject == nil then\n broadcastToColor(\"Hover a clue or card with clues and try again.\", messageColor, \"Yellow\")\n return\n elseif hoveredObject.type == \"Card\" then\n cardName = hoveredObject.getName()\n local searchResult = searchLib.onObject(hoveredObject, \"isClue\")\n\n if #searchResult == 0 then\n broadcastToColor(\"This card does not have any clues on it.\", messageColor, \"Yellow\")\n return\n else\n clue = searchResult[1]\n end\n elseif hoveredObject.memo == \"clueDoom\" then\n if hoveredObject.is_face_down then\n broadcastToColor(\"This is a doom token and not a clue.\", messageColor, \"Yellow\")\n return\n end\n\n clue = hoveredObject\n local searchResult = searchLib.belowPosition(clue.getPosition(), \"isCard\")\n\n if #searchResult ~= 0 then\n cardName = searchResult[1].getName()\n end\n elseif hoveredObject.type == \"Infinite\" and hoveredObject.getName() == \"Clue tokens\" then\n clue = hoveredObject.takeObject()\n cardName = \"token pool\"\n else\n broadcastToColor(\"Hover a clue or card with clues and try again.\", messageColor, \"Yellow\")\n return\n end\n\n local clickableClues = optionPanelApi.getOptions()[\"useClueClickers\"]\n\n -- handling for calling this for a specific mat via hotkey\n local playerName, matColor, pos\n if Player[playerColor] and Player[playerColor].seated then\n playerName = Player[playerColor].steam_name\n matColor = playmatApi.getMatColor(playerColor)\n else\n playerName = playerColor\n matColor = playerColor\n end\n\n if clickableClues then\n pos = {x = 0.49, y = 2.66, z = 0.00}\n playmatApi.updateCounter(matColor, \"ClickableClueCounter\", _, 1)\n else\n pos = playmatApi.transformLocalPosition({x = -1.12, y = 0.05, z = 0.7}, matColor)\n end\n \n local rot = playmatApi.returnRotation(matColor)\n\n -- check if found clue is a stack or single token\n if clue.getQuantity() \u003e 1 then\n clue.takeObject({position = pos, rotation = rot})\n else\n clue.setPositionSmooth(pos)\n clue.setRotation(rot)\n end\n\n if cardName then\n broadcastToAll(playerName .. \" took one clue from \" .. cardName .. \".\", \"White\")\n else\n broadcastToAll(playerName .. \" took one clue.\", \"White\")\n end\n\n victoryDisplayApi.update()\nend\n\n-- broadcasts the bless/curse status to the calling player\nfunction showBlessCurseStatus(playerColor)\n blessCurseManagerApi.broadcastStatus(playerColor)\nend\n\n-- adds Wendy's menu to the hovered card\nfunction addBlurseSealingMenu(playerColor, hoveredObject)\n blessCurseManagerApi.addBlurseSealingMenu(playerColor, hoveredObject)\nend\n\n-- Simple method to check if the given point is in a specified area\n---@param point tts__Vector Point to check, only x and z values are relevant\n---@param bounds table Defined area to see if the point is within\nfunction inArea(point, bounds)\n return (point.x \u003e bounds.minX\n and point.x \u003c bounds.maxX\n and point.z \u003e bounds.minZ\n and point.z \u003c bounds.maxZ)\nend\n\n-- capitalizes the first letter\nfunction titleCase(str)\n local first = str:sub(1, 1)\n local rest = str:sub(2)\n return first:upper() .. rest:lower()\nend\n\n-- returns the color of the first seated player\nfunction getFirstSeatedPlayer()\n for _, color in ipairs(getSeatedPlayers()) do\n return color\n end\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"core/VictoryDisplayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local VictoryDisplayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getVictoryDisplay()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"VictoryDisplay\")\n end\n\n -- triggers an update of the victory count\n ---@param delay? number Delay in seconds after which the update call is executed\n VictoryDisplayApi.update = function(delay)\n getVictoryDisplay().call(\"startUpdate\", delay)\n end\n\n -- moves a card to the victory display (in the first empty spot)\n ---@param object tts__Object Object that should be checked and potentially moved\n VictoryDisplayApi.placeCard = function(object)\n if object ~= nil and object.tag == \"Card\" then\n getVictoryDisplay().call(\"placeCard\", object)\n end\n end\n\n return VictoryDisplayApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/GameKeyHandler\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/NavigationOverlayApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local NavigationOverlayApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getNOHandler()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"NavigationOverlayHandler\")\n end\n\n -- copies the visibility for the Navigation overlay\n ---@param startColor string Color of the player to copy from\n ---@param targetColor string Color of the targeted player\n NavigationOverlayApi.copyVisibility = function(startColor, targetColor)\n getNOHandler().call(\"copyVisibility\", {\n startColor = startColor,\n targetColor = targetColor\n })\n end\n\n -- changes the Navigation Overlay view (\"Full View\" --\u003e \"Play Areas\" --\u003e \"Closed\" etc.)\n ---@param playerColor string Color of the player to update the visibility for\n NavigationOverlayApi.cycleVisibility = function(playerColor)\n getNOHandler().call(\"cycleVisibility\", playerColor)\n end\n\n -- loads the specified camera for a player\n ---@param player tts__Player Player whose camera should be moved\n ---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to\n NavigationOverlayApi.loadCamera = function(player, camera)\n getNOHandler().call(\"loadCameraFromApi\", {\n player = player,\n camera = camera\n })\n end\n\n return NavigationOverlayApi\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "go_game_piece_white", @@ -205404,7 +208621,7 @@ }, "ImageScalar": 1, "ImageSecondaryURL": "", - "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2172484009093238162/ACF3BBD93CB517B0BD0952E9BB78A2D35A62F377/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2467486908540932616/8370C75D2789E1332836D8C2A31D32542153DE85/", "WidthScale": 0 }, "Description": "Press a numpad key to spawn the indicated token.", @@ -205522,7 +208739,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/NavigationOverlayHandler\")\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/NavigationOverlayHandler\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nfullButtonData = {\n { id = \"1\", width = \"84\", height = \"33\", offset = \"1 2\" }, -- 1. Act/Agenda\n { id = \"2\", width = \"78\", height = \"69\", offset = \"1 -62\" }, -- 2. Map\n { id = \"3\", width = \"70\", height = \"36\", offset = \"-38 -126\" }, -- 3. White\n { id = \"4\", width = \"70\", height = \"36\", offset = \"38 -126\" }, -- 4. Orange\n { id = \"5\", width = \"36\", height = \"70\", offset = \"-63 -66\" }, -- 5. Green\n { id = \"6\", width = \"36\", height = \"70\", offset = \"63 -66\" }, -- 6. Red\n { id = \"7\", width = \"38\", height = \"38\", offset = \"-65 -3\" }, -- 7. Victory\n { id = \"8\", width = \"40\", height = \"40\", offset = \"65 -3\" }, -- 8. Guide\n { id = \"9\", width = \"56\", height = \"16\", offset = \"1 -20\" }, -- 9. Player count\n { id = \"10\", width = \"36\", height = \"16\", offset = \"1 -102\" }, -- 10. Bless/Curse\n { id = \"11\", width = \"168\", height = \"56\", offset = \"1 47\" }, -- 11. Scenarios\n { id = \"12\", width = \"52\", height = \"53\", offset = \"-154 134\" }, -- 12. Player card panel\n { id = \"13\", width = \"22\", height = \"22\", offset = \"-116 132\" }, -- 13. Search card panel\n { id = \"14\", width = \"120\", height = \"75\", offset = \"-152 70\" }, -- 14. Player card display\n { id = \"15\", width = \"40\", height = \"54\", offset = \"-150 -38\" }, -- 15. Deck builder\n { id = \"16\", width = \"104\", height = \"84\", offset = \"-154 -114\" }, -- 16. Rules area\n { id = \"17\", width = \"100\", height = \"170\", offset = \"152 72\" }, -- 17. Cycle area\n { id = \"18\", width = \"56\", height = \"60\", offset = \"182 -124\" }, -- 18. Additions\n { id = \"19\", width = \"20\", height = \"20\", offset = \"0 150\" }, -- 19. Shrink\n { id = \"20\", width = \"20\", height = \"20\", offset = \"20 150\" }, -- 20. Close\n { id = \"21\", width = \"20\", height = \"20\", offset = \"-20 150\" } -- 21. Settings\n}\n\nplayButtonData = {\n { id = \"1\", width = \"80\", height = \"33\", offset = \"0 55\" },\n { id = \"2\", width = \"78\", height = \"70\", offset = \"0 -8\" },\n { id = \"3\", width = \"68\", height = \"32\", offset = \"-36 -71\" },\n { id = \"4\", width = \"68\", height = \"32\", offset = \"36 -71\" },\n { id = \"5\", width = \"35\", height = \"66\", offset = \"-65 -10\" },\n { id = \"6\", width = \"35\", height = \"66\", offset = \"65 -10\" },\n { id = \"7\", width = \"38\", height = \"38\", offset = \"-66 52\" },\n { id = \"8\", width = \"38\", height = \"38\", offset = \"66 52\" },\n { id = \"9\", width = \"50\", height = \"12\", offset = \"0 33\" },\n { id = \"10\", width = \"32\", height = \"12\", offset = \"0 -48\" },\n { id = \"19\", width = \"20\", height = \"20\", offset = \"0 80\" },\n { id = \"20\", width = \"20\", height = \"20\", offset = \"20 80\" },\n { id = \"21\", width = \"20\", height = \"20\", offset = \"-20 80\" }\n}\n\n-- To-Do: dynamically get positions by linking to objects\ncameraData = {\n { position = { -1.6, 1.55, 0 }, distance = 18 }, -- 1. Act/Agenda\n { position = { -28, 1.55, 0 }, distance = -1 }, -- 2. Map\n { position = { -31.6, 1.55, 26.4 }, distance = -1 }, -- 3. Green playmat\n { position = { -55, 1.55, 12.05 }, distance = -1 }, -- 4. White playmat\n { position = { -55, 1.55, -11.48 }, distance = -1 }, -- 5. Orange playmat\n { position = { -31.6, 1.55, -26.4 }, distance = -1 }, -- 6. Red playmat\n { position = { -3, 1.55, 30 }, distance = 16 }, -- 7. Victory / SetAside\n { position = { -3, 1.55, -26.76 }, distance = 16 }, -- 8. Guide\n { position = { -11.83, 1.55, 0 }, distance = 10 }, -- 9. Player count\n { position = { -48.35, 1.55, 0 }, distance = 10 }, -- 10. Bless/Curse\n { position = { 12.56, 1.55, 0 }, distance = 45 }, -- 11. Scenarios\n { position = { 57.8, 1.55, 71 }, distance = 22 }, -- 12. Player card panel\n { position = { 60.38, 1.55, 56 }, distance = 10 }, -- 13. Card search panel\n { position = { 27.48, 1.55, 71 }, distance = 35 }, -- 14. Player card area\n { position = { -19.48, 1.55, 71 }, distance = 22 }, -- 15. Deck builder\n { position = { -52.92, 1.55, 71 }, distance = 42 }, -- 16. Rules area\n { position = { 26, 1.55, -71 }, distance = 65 }, -- 17. Cycle area\n { position = { -59.08, 1.55, -83 }, distance = 27 } -- 18. Additions\n}\n\nlocal settingsOpenForColor\nlocal visibility = {}\nlocal claims = {}\nlocal pitch = {}\nlocal distance = {}\n\n---------------------------------------------------------\n-- save/load functionality\n---------------------------------------------------------\n\nfunction onSave()\n return JSON.encode({\n visibility = visibility,\n claims = claims,\n pitch = pitch,\n distance = distance\n })\nend\n\nfunction onLoad(savedData)\n if savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n visibility = loadedData.visibility\n claims = loadedData.claims\n pitch = loadedData.pitch\n distance = loadedData.distance\n else\n local allColors = Player.getColors()\n\n for _, color in ipairs(allColors) do\n -- default state for claims\n claims[color] = {}\n\n -- default state for visibility\n visibility[color] = { full = false, play = false }\n end\n end\n\n createXmlButtons()\n updateVisibility()\nend\n\n---------------------------------------------------------\n-- visibility related functions\n---------------------------------------------------------\n\nfunction cycleVisibility(color)\n setVisibility(\"next\", color)\nend\n\nfunction copyVisibility(params)\n visibility[params.targetColor] = {\n full = visibility[params.startColor].full,\n play = visibility[params.startColor].play\n }\n updateVisibility()\nend\n\nfunction setVisibility(type, color)\n if type == \"next\" then\n if visibility[color].full then\n visibility[color] = { full = false, play = true }\n elseif visibility[color].play then\n visibility[color] = { full = false, play = false }\n else\n visibility[color] = { full = true, play = false }\n end\n elseif type == \"toggle\" then\n visibility[color] = {\n full = not visibility[color].full,\n play = not visibility[color].play\n }\n else\n visibility[color] = { full = false, play = false }\n end\n\n updateVisibility()\nend\n\n-- update XML visibility\nfunction updateVisibility()\n local colorString = { full = \"\", play = \"\" }\n\n for color, v in pairs(visibility) do\n if v.full then\n if colorString.full == \"\" then\n colorString.full = color\n else\n colorString.full = colorString.full .. '|' .. color\n end\n elseif v.play then\n if colorString.play == \"\" then\n colorString.play = color\n else\n colorString.play = colorString.play .. '|' .. color\n end\n end\n end\n\n -- update the visibility on the XML\n UI.setAttribute(\"navPanelFull\", \"visibility\", colorString.full)\n UI.setAttribute(\"navPanelPlay\", \"visibility\", colorString.play)\n UI.setAttribute(\"navPanelFull\", \"active\", colorString.full ~= \"\")\n UI.setAttribute(\"navPanelPlay\", \"active\", colorString.play ~= \"\")\nend\n\n---------------------------------------------------------\n-- XML button creation\n---------------------------------------------------------\n\nfunction createXmlButtons()\n local ui = UI.getXmlTable()\n ui = createXmlButtonHelper(ui, {\n data = fullButtonData,\n id = \"navPanelFull\",\n overlay = \"OverlayLarge\"\n })\n ui = createXmlButtonHelper(ui, {\n data = playButtonData,\n id = \"navPanelPlay\",\n overlay = \"OverlaySmall\"\n })\n UI.setXmlTable(ui)\nend\n\n-- XML button creation\nfunction createXmlButtonHelper(ui, params)\n local color\n local guid = self.getGUID()\n local xml = findTagWithId(ui, params.id)\n\n -- add basic image\n xml.children = { {\n tag = \"image\",\n attributes = {\n id = \"backgroundImage\",\n image = params.overlay\n }\n } }\n\n -- add all buttons\n for _, d in ipairs(params.data) do\n table.insert(xml.children, {\n tag = \"button\",\n attributes = {\n onClick = guid .. \"/buttonClicked\",\n id = d.id,\n height = d.height,\n width = d.width,\n offsetXY = d.offset,\n color = \"rgba(0,1,0,0)\"\n }\n })\n end\n return ui\nend\n\nfunction findTagWithId(ui, id)\n for _, obj in ipairs(ui) do\n if obj.attributes and obj.attributes.id and obj.attributes.id == id then return obj end\n if obj.children then\n local result = findTagWithId(obj.children, id)\n if result then return result end\n end\n end\n return nil\nend\n\n---------------------------------------------------------\n-- core functionality\n---------------------------------------------------------\n\n-- handles all button clicks\nfunction buttonClicked(player, _, id)\n local index = tonumber(id) or \"\"\n\n if index == 19 then\n setVisibility(\"toggle\", player.color)\n elseif index == 20 then\n setVisibility(\"close\", player.color)\n elseif index == 21 then\n toggleSettings(player)\n else\n loadCamera(player, index)\n end\nend\n\n-- generates a table with rectangular bounds for provided objects\nfunction getDynamicViewBounds(objList)\n local count = 0\n local totalBounds = {\n minX = 0,\n maxX = -70,\n minZ = 60,\n maxZ = -60\n }\n\n for _, obj in pairs(objList) do\n if not obj.hasTag(\"CameraZoom_ignore\") and not obj.hasTag(\"CampaignLog\") then\n count = count + 1\n local bounds = obj.getBounds()\n local x1 = bounds['center'][1] - bounds['size'][1] / 2\n local x2 = bounds['center'][1] + bounds['size'][1] / 2\n local z1 = bounds['center'][3] - bounds['size'][3] / 2\n local z2 = bounds['center'][3] + bounds['size'][3] / 2\n\n totalBounds.minX = math.min(x1, totalBounds.minX)\n totalBounds.maxX = math.max(x2, totalBounds.maxX)\n totalBounds.minZ = math.min(z1, totalBounds.minZ)\n totalBounds.maxZ = math.max(z2, totalBounds.maxZ)\n end\n end\n\n -- default values (mainly for play area if nothing is found)\n if count == 0 then\n totalBounds.minX = -10\n totalBounds.maxX = -50\n totalBounds.minZ = -20\n totalBounds.maxZ = 20\n end\n\n totalBounds.middleX = (totalBounds.maxX + totalBounds.minX) / 2\n totalBounds.middleZ = (totalBounds.maxZ + totalBounds.minZ) / 2\n totalBounds.diffX = totalBounds.maxX - totalBounds.minX\n totalBounds.diffZ = totalBounds.maxZ - totalBounds.minZ\n\n return totalBounds\nend\n\nfunction loadCameraFromApi(params)\n loadCamera(params.player, params.camera)\nend\n\n-- loads the specified camera for a player\n---@param player tts__Player Player whose camera should be moved\n---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to\nfunction loadCamera(player, camera)\n local lookHere, index, matColor\n local matColorList = { \"White\", \"Orange\", \"Green\", \"Red\" }\n local indexList = {\n White = 3,\n Orange = 4,\n Green = 5,\n Red = 6\n }\n\n if tonumber(camera) then\n index = tonumber(camera)\n matColor = matColorList[index - 2] -- mat index 1 - 4\n else\n index = indexList[camera]\n matColor = camera\n end\n\n -- dynamic view of the play area\n if index == 2 then\n -- search the scripting zone on the play area for objects\n local bounds = getDynamicViewBounds(getObjectFromGUID(\"a2f932\").getObjects())\n\n lookHere = {\n position = { bounds.middleX, 1.55, bounds.middleZ },\n yaw = 90,\n distance = 0.8 * math.max(bounds.diffX, bounds.diffZ) + 7\n }\n -- dynamic view of the clicked play mat\n elseif index \u003e= 3 and index \u003c= 6 then\n -- check if anyone (except for yourself) has claimed this color\n local isClaimed = false\n\n for playerColor, playerTable in pairs(claims) do\n if playerColor ~= player.color and playerTable[matColor] then\n isClaimed = true\n break\n end\n end\n\n -- swap to that color if it isn't claimed by someone else\n if #getSeatedPlayers() == 1 or not isClaimed then\n local newPlayerColor = playmatApi.getPlayerColor(matColor)\n copyVisibility({ startColor = player.color, targetColor = newPlayerColor })\n player.changeColor(newPlayerColor)\n player = Player[newPlayerColor]\n end\n\n -- search on the playmat for objects\n local bounds = getDynamicViewBounds(playmatApi.searchAroundPlaymat(matColor))\n\n lookHere = {\n position = { bounds.middleX, 0, bounds.middleZ },\n yaw = playmatApi.returnRotation(matColor).y + 180,\n distance = 0.42 * math.max(bounds.diffX, bounds.diffZ) + 7\n }\n end\n\n -- get default data if no dynamic view (play area or play mat) was loaded\n if not lookHere then\n lookHere = cameraData[index]\n lookHere.yaw = 90\n end\n\n -- set pitch to default if not edited\n lookHere.pitch = pitch[player.color] or 75\n\n -- update distance based on selected multiplier\n lookHere.distance = lookHere.distance * (distance[player.color] or 100) / 100\n\n -- delay is to account for colorswap\n Wait.frames(function() player.lookAt(lookHere) end, 2)\nend\n\n---------------------------------------------------------\n-- settings related functionality\n---------------------------------------------------------\n\n-- claims a color for a player\nfunction claimColor(player, color)\n local currentState = claims[player.color][color]\n claims[player.color][color] = not currentState\nend\n\nfunction loadDefaultSettings(player)\n -- reset claims for that player\n for _, color in ipairs(Player.getColors()) do\n claims[player.color][color] = (player.color == color)\n end\n\n -- reset pitch/distance for that player\n pitch[player.color] = nil\n distance[player.color] = nil\n\n -- update the UI accordingly\n updateSettingsUI(player)\nend\n\n-- called by clicking a toggle\nfunction toggleSettings(player)\n if settingsOpenForColor == player.color then\n settingsOpenForColor = nil\n UI.setAttribute(\"navPanelSettings\", \"active\", false)\n elseif settingsOpenForColor then\n broadcastToColor(\"Someone else is currently using the settings. Please wait and try again.\", player.color, \"Yellow\")\n else\n settingsOpenForColor = player.color\n\n updateSettingsUI(player)\n UI.setAttribute(\"navPanelSettings\", \"visibility\", player.color)\n UI.setAttribute(\"navPanelSettings\", \"active\", true)\n end\nend\n\n-- called by the navigation overlay options\nfunction updatePitch(player, number)\n pitch[player.color] = number\nend\n\n-- called by the navigation overlay options\nfunction updateDistance(player, number)\n distance[player.color] = number\nend\n\n-- updates the settings UI for the provided player\nfunction updateSettingsUI(player)\n -- update the sliders\n UI.setAttribute(\"sliderPitch\", \"value\", pitch[player.color] or 75)\n UI.setAttribute(\"sliderDistance\", \"value\", distance[player.color] or 100)\n \n -- update the claims\n local matColorList = { \"White\", \"Orange\", \"Green\", \"Red\" }\n for _, matColor in pairs(matColorList) do\n UI.setAttribute(\"claim\" .. matColor, \"isOn\", claims[player.color][matColor] or false)\n end\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/NavigationOverlayHandler\")\nend)\n__bundle_register(\"core/NavigationOverlayHandler\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\nfullButtonData = {\n { id = \"1\", width = \"84\", height = \"33\", offset = \"1 2\" }, -- 1. Act/Agenda\n { id = \"2\", width = \"78\", height = \"69\", offset = \"1 -62\" }, -- 2. Map\n { id = \"3\", width = \"70\", height = \"36\", offset = \"-38 -126\" }, -- 3. White\n { id = \"4\", width = \"70\", height = \"36\", offset = \"38 -126\" }, -- 4. Orange\n { id = \"5\", width = \"36\", height = \"70\", offset = \"-63 -66\" }, -- 5. Green\n { id = \"6\", width = \"36\", height = \"70\", offset = \"63 -66\" }, -- 6. Red\n { id = \"7\", width = \"38\", height = \"38\", offset = \"-65 -3\" }, -- 7. Victory\n { id = \"8\", width = \"40\", height = \"40\", offset = \"65 -3\" }, -- 8. Guide\n { id = \"9\", width = \"56\", height = \"16\", offset = \"1 -20\" }, -- 9. Player count\n { id = \"10\", width = \"36\", height = \"16\", offset = \"1 -102\" }, -- 10. Bless/Curse\n { id = \"11\", width = \"168\", height = \"56\", offset = \"1 47\" }, -- 11. Scenarios\n { id = \"12\", width = \"52\", height = \"53\", offset = \"-154 134\" }, -- 12. Player card panel\n { id = \"13\", width = \"22\", height = \"22\", offset = \"-116 132\" }, -- 13. Search card panel\n { id = \"14\", width = \"120\", height = \"75\", offset = \"-152 70\" }, -- 14. Player card display\n { id = \"15\", width = \"40\", height = \"54\", offset = \"-150 -38\" }, -- 15. Deck builder\n { id = \"16\", width = \"104\", height = \"84\", offset = \"-154 -114\" }, -- 16. Rules area\n { id = \"17\", width = \"100\", height = \"170\", offset = \"152 72\" }, -- 17. Cycle area\n { id = \"18\", width = \"56\", height = \"60\", offset = \"182 -124\" }, -- 18. Additions\n { id = \"19\", width = \"20\", height = \"20\", offset = \"0 150\" }, -- 19. Shrink\n { id = \"20\", width = \"20\", height = \"20\", offset = \"20 150\" }, -- 20. Close\n { id = \"21\", width = \"20\", height = \"20\", offset = \"-20 150\" } -- 21. Settings\n}\n\nplayButtonData = {\n { id = \"1\", width = \"80\", height = \"33\", offset = \"0 55\" },\n { id = \"2\", width = \"78\", height = \"70\", offset = \"0 -8\" },\n { id = \"3\", width = \"68\", height = \"32\", offset = \"-36 -71\" },\n { id = \"4\", width = \"68\", height = \"32\", offset = \"36 -71\" },\n { id = \"5\", width = \"35\", height = \"66\", offset = \"-65 -10\" },\n { id = \"6\", width = \"35\", height = \"66\", offset = \"65 -10\" },\n { id = \"7\", width = \"38\", height = \"38\", offset = \"-66 52\" },\n { id = \"8\", width = \"38\", height = \"38\", offset = \"66 52\" },\n { id = \"9\", width = \"50\", height = \"12\", offset = \"0 33\" },\n { id = \"10\", width = \"32\", height = \"12\", offset = \"0 -48\" },\n { id = \"19\", width = \"20\", height = \"20\", offset = \"0 80\" },\n { id = \"20\", width = \"20\", height = \"20\", offset = \"20 80\" },\n { id = \"21\", width = \"20\", height = \"20\", offset = \"-20 80\" }\n}\n\n-- To-Do: dynamically get positions by linking to objects\ncameraData = {\n { position = { -1.6, 1.55, 0 }, distance = 18 }, -- 1. Act/Agenda\n { position = { -28, 1.55, 0 }, distance = -1 }, -- 2. Map\n { position = { -31.6, 1.55, 26.4 }, distance = -1 }, -- 3. Green playmat\n { position = { -55, 1.55, 12.05 }, distance = -1 }, -- 4. White playmat\n { position = { -55, 1.55, -11.48 }, distance = -1 }, -- 5. Orange playmat\n { position = { -31.6, 1.55, -26.4 }, distance = -1 }, -- 6. Red playmat\n { position = { -3, 1.55, 30 }, distance = 16 }, -- 7. Victory / SetAside\n { position = { -3, 1.55, -26.76 }, distance = 16 }, -- 8. Guide\n { position = { -11.83, 1.55, 0 }, distance = 10 }, -- 9. Player count\n { position = { -48.35, 1.55, 0 }, distance = 10 }, -- 10. Bless/Curse\n { position = { 12.56, 1.55, 0 }, distance = 45 }, -- 11. Scenarios\n { position = { 57.8, 1.55, 71 }, distance = 22 }, -- 12. Player card panel\n { position = { 60.38, 1.55, 56 }, distance = 10 }, -- 13. Card search panel\n { position = { 27.48, 1.55, 71 }, distance = 35 }, -- 14. Player card area\n { position = { -19.48, 1.55, 71 }, distance = 22 }, -- 15. Deck builder\n { position = { -52.92, 1.55, 71 }, distance = 42 }, -- 16. Rules area\n { position = { 26, 1.55, -71 }, distance = 65 }, -- 17. Cycle area\n { position = { -59.08, 1.55, -83 }, distance = 27 } -- 18. Additions\n}\n\nlocal settingsOpenForColor\nlocal visibility = {}\nlocal claims = {}\nlocal pitch = {}\nlocal distance = {}\n\n---------------------------------------------------------\n-- save/load functionality\n---------------------------------------------------------\n\nfunction onSave()\n return JSON.encode({\n visibility = visibility,\n claims = claims,\n pitch = pitch,\n distance = distance\n })\nend\n\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n visibility = loadedData.visibility\n claims = loadedData.claims\n pitch = loadedData.pitch\n distance = loadedData.distance\n else\n local allColors = Player.getColors()\n\n for _, color in ipairs(allColors) do\n -- default state for claims\n claims[color] = {}\n\n -- default state for visibility\n visibility[color] = { full = false, play = false }\n end\n end\n\n createXmlButtons()\n updateVisibility()\nend\n\n---------------------------------------------------------\n-- visibility related functions\n---------------------------------------------------------\n\nfunction cycleVisibility(color)\n setVisibility(\"next\", color)\nend\n\nfunction copyVisibility(params)\n visibility[params.targetColor] = {\n full = visibility[params.startColor].full,\n play = visibility[params.startColor].play\n }\n updateVisibility()\nend\n\nfunction setVisibility(type, color)\n if type == \"next\" then\n if visibility[color].full then\n visibility[color] = { full = false, play = true }\n elseif visibility[color].play then\n visibility[color] = { full = false, play = false }\n else\n visibility[color] = { full = true, play = false }\n end\n elseif type == \"toggle\" then\n visibility[color] = {\n full = not visibility[color].full,\n play = not visibility[color].play\n }\n else\n visibility[color] = { full = false, play = false }\n end\n\n updateVisibility()\nend\n\n-- update XML visibility\nfunction updateVisibility()\n local colorString = { full = \"\", play = \"\" }\n\n for color, v in pairs(visibility) do\n if v.full then\n if colorString.full == \"\" then\n colorString.full = color\n else\n colorString.full = colorString.full .. '|' .. color\n end\n elseif v.play then\n if colorString.play == \"\" then\n colorString.play = color\n else\n colorString.play = colorString.play .. '|' .. color\n end\n end\n end\n\n -- update the visibility on the XML\n UI.setAttribute(\"navPanelFull\", \"visibility\", colorString.full)\n UI.setAttribute(\"navPanelPlay\", \"visibility\", colorString.play)\n UI.setAttribute(\"navPanelFull\", \"active\", colorString.full ~= \"\")\n UI.setAttribute(\"navPanelPlay\", \"active\", colorString.play ~= \"\")\nend\n\n---------------------------------------------------------\n-- XML button creation\n---------------------------------------------------------\n\nfunction createXmlButtons()\n local ui = UI.getXmlTable()\n ui = createXmlButtonHelper(ui, {\n data = fullButtonData,\n id = \"navPanelFull\",\n overlay = \"OverlayLarge\"\n })\n ui = createXmlButtonHelper(ui, {\n data = playButtonData,\n id = \"navPanelPlay\",\n overlay = \"OverlaySmall\"\n })\n UI.setXmlTable(ui)\nend\n\n-- XML button creation\nfunction createXmlButtonHelper(ui, params)\n local color\n local guid = self.getGUID()\n local xml = findTagWithId(ui, params.id)\n\n -- add basic image\n xml.children = { {\n tag = \"image\",\n attributes = {\n id = \"backgroundImage\",\n image = params.overlay\n }\n } }\n\n -- add all buttons\n for _, d in ipairs(params.data) do\n table.insert(xml.children, {\n tag = \"button\",\n attributes = {\n onClick = guid .. \"/buttonClicked\",\n id = d.id,\n height = d.height,\n width = d.width,\n offsetXY = d.offset,\n color = \"rgba(0,1,0,0)\"\n }\n })\n end\n return ui\nend\n\nfunction findTagWithId(ui, id)\n for _, obj in ipairs(ui) do\n if obj.attributes and obj.attributes.id and obj.attributes.id == id then return obj end\n if obj.children then\n local result = findTagWithId(obj.children, id)\n if result then return result end\n end\n end\n return nil\nend\n\n---------------------------------------------------------\n-- core functionality\n---------------------------------------------------------\n\n-- handles all button clicks\nfunction buttonClicked(player, _, id)\n local index = tonumber(id) or \"\"\n\n if index == 19 then\n setVisibility(\"toggle\", player.color)\n elseif index == 20 then\n setVisibility(\"close\", player.color)\n elseif index == 21 then\n toggleSettings(player)\n else\n loadCamera(player, index)\n end\nend\n\n-- generates a table with rectangular bounds for provided objects\nfunction getDynamicViewBounds(objList)\n local count = 0\n local totalBounds = {\n minX = 0,\n maxX = -70,\n minZ = 60,\n maxZ = -60\n }\n\n for _, obj in pairs(objList) do\n if not obj.hasTag(\"CameraZoom_ignore\") and not obj.hasTag(\"CampaignLog\") then\n count = count + 1\n local bounds = obj.getBounds()\n local x1 = bounds['center'][1] - bounds['size'][1] / 2\n local x2 = bounds['center'][1] + bounds['size'][1] / 2\n local z1 = bounds['center'][3] - bounds['size'][3] / 2\n local z2 = bounds['center'][3] + bounds['size'][3] / 2\n\n totalBounds.minX = math.min(x1, totalBounds.minX)\n totalBounds.maxX = math.max(x2, totalBounds.maxX)\n totalBounds.minZ = math.min(z1, totalBounds.minZ)\n totalBounds.maxZ = math.max(z2, totalBounds.maxZ)\n end\n end\n\n -- default values (mainly for play area if nothing is found)\n if count == 0 then\n totalBounds.minX = -10\n totalBounds.maxX = -50\n totalBounds.minZ = -20\n totalBounds.maxZ = 20\n end\n\n totalBounds.middleX = (totalBounds.maxX + totalBounds.minX) / 2\n totalBounds.middleZ = (totalBounds.maxZ + totalBounds.minZ) / 2\n totalBounds.diffX = totalBounds.maxX - totalBounds.minX\n totalBounds.diffZ = totalBounds.maxZ - totalBounds.minZ\n\n return totalBounds\nend\n\nfunction loadCameraFromApi(params)\n loadCamera(params.player, params.camera)\nend\n\n-- loads the specified camera for a player\n---@param player tts__Player Player whose camera should be moved\n---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to\nfunction loadCamera(player, camera)\n local lookHere, index, matColor\n local matColorList = { \"White\", \"Orange\", \"Green\", \"Red\" }\n local indexList = {\n White = 3,\n Orange = 4,\n Green = 5,\n Red = 6\n }\n\n if tonumber(camera) then\n index = tonumber(camera)\n matColor = matColorList[index - 2] -- mat index 1 - 4\n else\n index = indexList[camera]\n matColor = camera\n end\n\n -- dynamic view of the play area\n if index == 2 then\n -- search the scripting zone on the play area for objects\n local bounds = getDynamicViewBounds(getObjectFromGUID(\"a2f932\").getObjects())\n\n lookHere = {\n position = { bounds.middleX, 1.55, bounds.middleZ },\n yaw = 90,\n distance = 0.8 * math.max(bounds.diffX, bounds.diffZ) + 7\n }\n -- dynamic view of the clicked play mat\n elseif index \u003e= 3 and index \u003c= 6 then\n -- check if anyone (except for yourself) has claimed this color\n local isClaimed = false\n\n for playerColor, playerTable in pairs(claims) do\n if playerColor ~= player.color and playerTable[matColor] then\n isClaimed = true\n break\n end\n end\n\n -- swap to that color if it isn't claimed by someone else\n if #getSeatedPlayers() == 1 or not isClaimed then\n local newPlayerColor = playmatApi.getPlayerColor(matColor)\n copyVisibility({ startColor = player.color, targetColor = newPlayerColor })\n player.changeColor(newPlayerColor)\n player = Player[newPlayerColor]\n end\n\n -- search on the playmat for objects\n local bounds = getDynamicViewBounds(playmatApi.searchAroundPlaymat(matColor))\n\n lookHere = {\n position = { bounds.middleX, 0, bounds.middleZ },\n yaw = playmatApi.returnRotation(matColor).y + 180,\n distance = 0.42 * math.max(bounds.diffX, bounds.diffZ) + 7\n }\n end\n\n -- get default data if no dynamic view (play area or play mat) was loaded\n if not lookHere then\n lookHere = cameraData[index]\n lookHere.yaw = 90\n end\n\n -- set pitch to default if not edited\n lookHere.pitch = pitch[player.color] or 75\n\n -- update distance based on selected multiplier\n lookHere.distance = lookHere.distance * (distance[player.color] or 100) / 100\n\n -- delay is to account for colorswap\n Wait.frames(function() player.lookAt(lookHere) end, 2)\nend\n\n---------------------------------------------------------\n-- settings related functionality\n---------------------------------------------------------\n\n-- claims a color for a player\nfunction claimColor(player, color)\n local currentState = claims[player.color][color]\n claims[player.color][color] = not currentState\nend\n\nfunction loadDefaultSettings(player)\n -- reset claims for that player\n for _, color in ipairs(Player.getColors()) do\n claims[player.color][color] = (player.color == color)\n end\n\n -- reset pitch/distance for that player\n pitch[player.color] = nil\n distance[player.color] = nil\n\n -- update the UI accordingly\n updateSettingsUI(player)\nend\n\n-- called by clicking a toggle\nfunction toggleSettings(player)\n if settingsOpenForColor == player.color then\n settingsOpenForColor = nil\n UI.setAttribute(\"navPanelSettings\", \"active\", false)\n elseif settingsOpenForColor then\n broadcastToColor(\"Someone else is currently using the settings. Please wait and try again.\", player.color, \"Yellow\")\n else\n settingsOpenForColor = player.color\n\n updateSettingsUI(player)\n UI.setAttribute(\"navPanelSettings\", \"visibility\", player.color)\n UI.setAttribute(\"navPanelSettings\", \"active\", true)\n end\nend\n\n-- called by the navigation overlay options\nfunction updatePitch(player, number)\n pitch[player.color] = number\nend\n\n-- called by the navigation overlay options\nfunction updateDistance(player, number)\n distance[player.color] = number\nend\n\n-- updates the settings UI for the provided player\nfunction updateSettingsUI(player)\n -- update the sliders\n UI.setAttribute(\"sliderPitch\", \"value\", pitch[player.color] or 75)\n UI.setAttribute(\"sliderDistance\", \"value\", distance[player.color] or 100)\n \n -- update the claims\n local matColorList = { \"White\", \"Orange\", \"Green\", \"Red\" }\n for _, matColor in pairs(matColorList) do\n UI.setAttribute(\"claim\" .. matColor, \"isOn\", claims[player.color][matColor] or false)\n end\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "{\"claims\":{\"Black\":[],\"Blue\":[],\"Brown\":[],\"Green\":[],\"Grey\":[],\"Orange\":[],\"Pink\":[],\"Purple\":[],\"Red\":[],\"Teal\":[],\"White\":[],\"Yellow\":[]},\"distance\":[],\"pitch\":[],\"visibility\":{\"Black\":{\"full\":false,\"play\":false},\"Blue\":{\"full\":false,\"play\":false},\"Brown\":{\"full\":false,\"play\":false},\"Green\":{\"full\":false,\"play\":false},\"Grey\":{\"full\":false,\"play\":false},\"Orange\":{\"full\":false,\"play\":false},\"Pink\":{\"full\":false,\"play\":false},\"Purple\":{\"full\":false,\"play\":false},\"Red\":{\"full\":false,\"play\":false},\"Teal\":{\"full\":false,\"play\":false},\"White\":{\"full\":false,\"play\":false},\"Yellow\":{\"full\":false,\"play\":false}}}", "MeasureMovement": false, "Name": "go_game_piece_black", @@ -205588,7 +208805,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/CampaignImporterExporter\")\nend)\n__bundle_register(\"accessories/CampaignImporterExporter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal blessCurseApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal deckImporterApi = require(\"arkhamdb/DeckImporterApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal optionPanelApi = require(\"core/OptionPanelApi\")\nlocal playAreaApi = require(\"core/PlayAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- base data for token creation\nlocal campaignTokenData = {\n Name = \"Custom_Model_Bag\",\n Transform = {\n posX = -21.25,\n posY = 1.68,\n posZ = 55.59,\n rotX = 0,\n rotY = 270,\n rotZ = 0,\n scaleX = 2,\n scaleY = 2,\n scaleZ = 2\n },\n Description = \"SCED Importer Token\",\n Tags = { \"ImporterToken\" },\n CustomMesh = {\n MeshURL = \"http://cloud-3.steamusercontent.com/ugc/943949966265929204/A38BB5D72419E6298385556D931877C0A1A55C17/\",\n DiffuseURL = \"http://cloud-3.steamusercontent.com/ugc/254843371583188147/920981125E37B5CEB6C400E3FD353A2C428DA969/\",\n ColliderURL = \"http://cloud-3.steamusercontent.com/ugc/943949966265929204/A38BB5D72419E6298385556D931877C0A1A55C17/\",\n Convex = true,\n MaterialIndex = 2,\n TypeIndex = 6,\n CustomShader = {\n SpecularColor = {\n r = 0.72,\n g = 0.51,\n b = 0.34\n },\n SpecularIntensity = 0.4,\n SpecularSharpness = 7.0,\n FresnelStrength = 0.0\n }\n }\n}\n\nfunction onLoad()\n self.createButton({\n click_function = \"createCampaignToken\",\n function_owner = self,\n label = \"Export\",\n tooltip = \"Create a campaign save token!\",\n position = { x = -1, y = 0.21, z = 0 },\n font_size = 400,\n width = 1400,\n height = 600,\n scale = { 0.5, 1, 0.5 }\n })\nend\n\nfunction onObjectLeaveContainer(container, _)\n if container.hasTag(\"ImporterToken\") then\n broadcastToAll(\"Removing objects from the Save Coin bag will break functionality. Please return the removed objects.\", \"Yellow\")\n end\nend\n\nfunction onObjectEnterContainer(container, _)\n if container.hasTag(\"ImporterToken\") then\n broadcastToAll(\"Adding objects to the Save Coin bag will break functionality. Please remove the objects.\", \"Yellow\")\n end\nend\n\n---------------------------------------------------------\n-- main import functions (split up to allow for Wait conditions)\n---------------------------------------------------------\n\nfunction onCollisionEnter(info)\n if info.collision_object.hasTag(\"ImporterToken\") then\n importFromToken(info.collision_object)\n end\nend\n\n-- Identifies import token, determines campaign box and downloads it (if needed)\nfunction importFromToken(coin)\n broadcastToAll(\"Campaign Import Initiated\")\n local importData = JSON.decode(coin.getGMNotes())\n local campaignBox = getObjectFromGUID(importData[\"box\"])\n\n if not campaignBox then\n broadcastToAll(\"Campaign Box not present on table!\", \"Red\")\n return\n end\n\n if campaignBox.type == \"Generic\" then\n campaignBox.call(\"buttonClick_download\")\n end\n\n Wait.condition(\n function()\n local campaignBox = getObjectFromGUID(importData[\"box\"])\n if #campaignBox.getObjects() \u003e 0 then\n placeCampaignFromToken(importData, coin)\n else\n restoreCampaignData(importData, coin)\n end\n end,\n function()\n local obj = getObjectFromGUID(importData[\"box\"])\n if obj == nil then\n return false\n else\n return obj.type == \"Bag\"\n end\n end,\n 2,\n function() broadcastToAll(\"Error loading campaign box\") end\n )\nend\n\n-- After box has been downloaded, places content on table\nfunction placeCampaignFromToken(importData, coin)\n getObjectFromGUID(importData[\"box\"]).call(\"buttonClick_place\")\n Wait.condition(\n function() restoreCampaignData(importData, coin) end,\n function() return findUniqueObjectWithTag(\"CampaignLog\") ~= nil end,\n 2,\n function() broadcastToAll(\"Error placing campaign box\") end\n )\nend\n\n-- After content is placed on table, conducts all the other import operations\nfunction restoreCampaignData(importData, coin)\n -- destroy existing campaign log\n findUniqueObjectWithTag(\"CampaignLog\").destruct()\n\n -- destroy existing \"additional player cards\" bag\n if importData[\"additionalIndex\"] then\n guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"AdditionalPlayerCardsBag\").destruct()\n end\n\n if coin.type == \"Bag\" then\n -- go over internal items and spawn them at the original position\n for _, objData in ipairs(coin.getData().ContainedObjects) do\n objData[\"Locked\"] = true\n spawnObjectData({data = objData})\n end\n else\n -- support for older save coins that stored the data serialized\n if importData[\"additionalIndex\"] then\n spawnObjectJSON({json = importData[\"additionalIndex\"]})\n end\n spawnObjectData({data = importData[\"log\"]})\n end\n\n coin.destruct()\n\n chaosBagApi.setChaosBagState(importData[\"bag\"])\n\n -- populate trauma values\n if importData[\"trauma\"] then\n setTrauma(importData[\"trauma\"])\n end\n\n -- populate ArkhamDB deck IDs\n if importData[\"decks\"] then\n deckImporterApi.setUiState(importData[\"decks\"])\n end\n\n playAreaApi.setInvestigatorCount(importData[\"clueCount\"])\n\n -- set campaign guide page\n local guide = findUniqueObjectWithTag(\"CampaignGuide\")\n if guide then\n Wait.condition(\n -- Called after the condition function returns true\n function() printToAll(\"Campaign Guide import successful!\") end,\n -- Condition function that is called continuously until it returns true or timeout is reached\n function() return guide.Book.setPage(importData[\"guide\"]) end,\n -- Amount of time in seconds until the Wait times out\n 2,\n -- Called if the Wait times out\n function() printToAll(\"Campaign Guide import failed!\") end\n )\n end\n\n Wait.time(function() optionPanelApi.loadSettings(importData[\"options\"]) end, 0.5)\n\n -- destroy Tour Starter token\n local tourStarter = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TourStarter\")\n if tourStarter then\n tourStarter.destruct()\n end\n\n -- restore PlayArea image\n playAreaApi.updateSurface(importData[\"playarea\"])\n\n broadcastToAll(\"Campaign successfully imported!\", \"Green\")\nend\n\n-- Creates a campaign token with save data encoded into GM Notes based on the current state of the table\nfunction createCampaignToken(_, playerColor, _)\n -- find active campaign\n local campaignBox\n for _, obj in ipairs(getObjectsWithTag(\"CampaignBox\")) do\n if obj.type == \"Bag\" and #obj.getObjects() == 0 then\n if not campaignBox then\n campaignBox = obj\n else\n broadcastToAll(\"Multiple empty campaign box detected; delete all but one.\", \"Red\")\n return\n end\n end\n end\n\n if not campaignBox then\n broadcastToAll(\"Campaign box with all placed objects not found!\", \"Red\")\n return\n end\n\n local campaignLog = findUniqueObjectWithTag(\"CampaignLog\")\n if campaignLog == nil then\n broadcastToAll(\"Campaign log not found!\", \"Red\")\n return\n end\n\n local additionalIndex = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"AdditionalPlayerCardsBag\")\n local traumaValues = { }\n local trauma = campaignLog.getVar(\"returnTrauma\")\n\n if trauma ~= nil then\n printToAll(\"Trauma values found in campaign log!\", \"Green\")\n trauma = campaignLog.call(\"returnTrauma\")\n for _, val in ipairs(trauma) do\n table.insert(traumaValues, val)\n end\n else\n printToAll(\"Trauma values could not be found in campaign log!\", \"Yellow\")\n end\n\n local campaignGuide = findUniqueObjectWithTag(\"CampaignGuide\")\n if campaignGuide == nil then\n broadcastToAll(\"Campaign guide not found!\", \"Red\")\n return\n end\n\n -- clean up chaos tokens\n blessCurseApi.removeAll(playerColor)\n chaosBagApi.releaseAllSealedTokens(playerColor)\n\n local campaignData = {\n box = campaignBox.getGUID(),\n log = campaignLog.getPosition(),\n bag = chaosBagApi.getChaosBagState(),\n trauma = traumaValues,\n decks = deckImporterApi.getUiState(),\n clueCount = playAreaApi.getInvestigatorCount(),\n playarea = playAreaApi.getSurface(),\n options = optionPanelApi.getOptions(),\n guide = campaignGuide.Book.getPage(),\n additionalIndex = additionalIndex.getPosition()\n }\n campaignTokenData.GMNotes = JSON.encode(campaignData)\n campaignTokenData.Nickname = campaignBox.getName() .. os.date(\" %b %d\") .. \" Save\"\n campaignTokenData.ContainedObjects = { }\n\n local indexData = additionalIndex.getData()\n indexData.Locked = false\n table.insert(campaignTokenData.ContainedObjects, indexData)\n\n local logData = campaignLog.getData()\n logData.Locked = false\n table.insert(campaignTokenData.ContainedObjects, logData)\n\n spawnObjectData({ data = campaignTokenData })\n broadcastToAll(\"Campaign successfully exported! Save coin object to import on a different save.\", \"Green\")\nend\n\n---------------------------------------------------------\n-- helper functions\n---------------------------------------------------------\n\nfunction findUniqueObjectWithTag(tag)\n local objects = getObjectsWithTag(tag)\n if not objects then return end\n\n if #objects == 1 then\n return objects[1]\n else\n broadcastToAll(\"More than one \" .. tag .. \" detected; delete all but one.\", \"Red\")\n end\nend\n\nfunction setTrauma(trauma)\n for i, matColor in ipairs({ \"White\", \"Orange\", \"Green\", \"Red\" }) do\n playmatApi.updateCounter(matColor, \"DamageCounter\", trauma[i])\n playmatApi.updateCounter(matColor, \"HorrorCounter\", trauma[i + 4])\n end\nend\nend)\n__bundle_register(\"arkhamdb/DeckImporterApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckImporterApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getDeckImporter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DeckImporter\")\n end\n\n ---@class uiStateTable\n ---@field redDeck string Deck ID to load for the red player\n ---@field orangeDeck string Deck ID to load for the orange player\n ---@field whiteDeck string Deck ID to load for the white player\n ---@field greenDeck string Deck ID to load for the green player\n ---@field privateDeck boolean True to load a private deck, false to load a public deck\n ---@field loadNewest boolean True if the most upgraded version of the deck should be loaded\n ---@field investigators boolean True if investigator cards should be spawned\n\n -- Returns a table with the full state of the UI, including options and deck IDs.\n -- This can be used to persist via onSave(), or provide values for a load operation\n ---@return uiStateTable uiStateTable Contains data about the current UI state\n DeckImporterApi.getUiState = function()\n local passthroughTable = {}\n for k,v in pairs(getDeckImporter().call(\"getUiState\")) do\n passthroughTable[k] = v\n end\n return passthroughTable\n end\n\n -- Updates the state of the UI based on the provided table. Any values not provided will be left the same.\n ---@return uiStateTable uiStateTable Contains data about the current UI state\n DeckImporterApi.setUiState = function(uiStateTable)\n return getDeckImporter().call(\"setUiState\", uiStateTable)\n end\n\n return DeckImporterApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n \n -- highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n \n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n \n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"util/SearchLib\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local SearchLib = {}\n local filterFunctions = {\n isActionToken = function(x) return x.getDescription() == \"Action Token\" end,\n isCard = function(x) return x.type == \"Card\" end,\n isDeck = function(x) return x.type == \"Deck\" end,\n isCardOrDeck = function(x) return x.type == \"Card\" or x.type == \"Deck\" end,\n isClue = function(x) return x.memo == \"clueDoom\" and x.is_face_down == false end,\n isTileOrToken = function(x) return x.type == \"Tile\" end\n }\n\n -- performs the actual search and returns a filtered list of object references\n ---@param pos tts__Vector Global position\n ---@param rot? tts__Vector Global rotation\n ---@param size table Size\n ---@param filter? string Name of the filter function\n ---@param direction? table Direction (positive is up)\n ---@param maxDistance? number Distance for the cast\n local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)\n local filterFunc\n if filter then\n filterFunc = filterFunctions[filter]\n end\n local searchResult = Physics.cast({\n origin = pos,\n direction = direction or { 0, 1, 0 },\n orientation = rot or { 0, 0, 0 },\n type = 3,\n size = size,\n max_distance = maxDistance or 0\n })\n\n -- filtering the result\n local objList = {}\n for _, v in ipairs(searchResult) do\n if not filter or filterFunc(v.hit_object) then\n table.insert(objList, v.hit_object)\n end\n end\n return objList\n end\n\n -- searches the specified area\n SearchLib.inArea = function(pos, rot, size, filter)\n return returnSearchResult(pos, rot, size, filter)\n end\n\n -- searches the area on an object\n SearchLib.onObject = function(obj, filter)\n pos = obj.getPosition()\n size = obj.getBounds().size:setAt(\"y\", 1)\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches the specified position (a single point)\n SearchLib.atPosition = function(pos, filter)\n size = { 0.1, 2, 0.1 }\n return returnSearchResult(pos, _, size, filter)\n end\n\n -- searches below the specified position (downwards until y = 0)\n SearchLib.belowPosition = function(pos, filter)\n direction = { 0, -1, 0 }\n maxDistance = pos.y\n return returnSearchResult(pos, _, size, filter, direction, maxDistance)\n end\n\n return SearchLib\nend\nend)\n__bundle_register(\"accessories/CampaignImporterExporter\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal blessCurseApi = require(\"chaosbag/BlessCurseManagerApi\")\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal deckImporterApi = require(\"arkhamdb/DeckImporterApi\")\nlocal guidReferenceApi = require(\"core/GUIDReferenceApi\")\nlocal optionPanelApi = require(\"core/OptionPanelApi\")\nlocal playAreaApi = require(\"core/PlayAreaApi\")\nlocal playmatApi = require(\"playermat/PlaymatApi\")\n\n-- base data for token creation\nlocal campaignTokenData = {\n Name = \"Custom_Model_Bag\",\n Transform = {\n posX = -21.25,\n posY = 1.68,\n posZ = 55.59,\n rotX = 0,\n rotY = 270,\n rotZ = 0,\n scaleX = 2,\n scaleY = 2,\n scaleZ = 2\n },\n Description = \"SCED Importer Token\",\n Tags = { \"ImporterToken\" },\n CustomMesh = {\n MeshURL = \"http://cloud-3.steamusercontent.com/ugc/943949966265929204/A38BB5D72419E6298385556D931877C0A1A55C17/\",\n DiffuseURL = \"http://cloud-3.steamusercontent.com/ugc/254843371583188147/920981125E37B5CEB6C400E3FD353A2C428DA969/\",\n ColliderURL = \"http://cloud-3.steamusercontent.com/ugc/943949966265929204/A38BB5D72419E6298385556D931877C0A1A55C17/\",\n Convex = true,\n MaterialIndex = 2,\n TypeIndex = 6,\n CustomShader = {\n SpecularColor = {\n r = 0.72,\n g = 0.51,\n b = 0.34\n },\n SpecularIntensity = 0.4,\n SpecularSharpness = 7.0,\n FresnelStrength = 0.0\n }\n }\n}\n\nfunction onLoad()\n self.createButton({\n click_function = \"createCampaignToken\",\n function_owner = self,\n label = \"Export\",\n tooltip = \"Create a campaign save token!\",\n position = { x = -1, y = 0.21, z = 0 },\n font_size = 400,\n width = 1400,\n height = 600,\n scale = { 0.5, 1, 0.5 }\n })\nend\n\nfunction onObjectLeaveContainer(container)\n if container.hasTag(\"ImporterToken\") then\n broadcastToAll(\"Removing objects from the Save Coin bag will break functionality. Please return the removed objects.\", \"Yellow\")\n end\nend\n\nfunction onObjectEnterContainer(container)\n if container.hasTag(\"ImporterToken\") then\n broadcastToAll(\"Adding objects to the Save Coin bag will break functionality. Please remove the objects.\", \"Yellow\")\n end\nend\n\n---------------------------------------------------------\n-- main import functions (split up to allow for Wait conditions)\n---------------------------------------------------------\n\nfunction onCollisionEnter(info)\n if info.collision_object.hasTag(\"ImporterToken\") then\n importFromToken(info.collision_object)\n end\nend\n\n-- identifies import token, determines campaign box and downloads it (if needed)\nfunction importFromToken(coin)\n broadcastToAll(\"Campaign Import Initiated\")\n local importData = JSON.decode(coin.getGMNotes())\n local campaignBox = getObjectFromGUID(importData[\"box\"])\n\n if not campaignBox then\n broadcastToAll(\"Campaign Box not present on table!\", \"Red\")\n return\n end\n\n if campaignBox.type == \"Generic\" then\n campaignBox.call(\"buttonClick_download\")\n end\n\n Wait.condition(\n function()\n local campaignBox = getObjectFromGUID(importData[\"box\"])\n if #campaignBox.getObjects() \u003e 0 then\n placeCampaignFromToken(importData, coin)\n else\n restoreCampaignData(importData, coin)\n end\n end,\n function()\n local obj = getObjectFromGUID(importData[\"box\"])\n if obj == nil then\n return false\n else\n return obj.type == \"Bag\"\n end\n end,\n 2,\n function() broadcastToAll(\"Error loading campaign box\") end\n )\nend\n\n-- after box has been downloaded, places content on table\nfunction placeCampaignFromToken(importData, coin)\n getObjectFromGUID(importData[\"box\"]).call(\"buttonClick_place\")\n Wait.condition(\n function() restoreCampaignData(importData, coin) end,\n function() return findUniqueObjectWithTag(\"CampaignLog\") ~= nil end,\n 2,\n function() broadcastToAll(\"Error placing campaign box\") end\n )\nend\n\n-- after content is placed on table, conducts all the other import operations\nfunction restoreCampaignData(importData, coin)\n -- go over internal items and respawn them (only storing campaign log and additional player cards)\n for _, objData in ipairs(coin.getData().ContainedObjects) do\n objData.Locked = true\n local spawnData = { data = objData }\n\n -- maybe restore position of item and destroy duplicate\n if objData.Nickname == \"Additional Player Cards\" then\n local additionalIndex = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"AdditionalPlayerCardsBag\")\n spawnData.position = additionalIndex.getPosition()\n additionalIndex.destruct()\n else\n local campaignLog = findUniqueObjectWithTag(\"CampaignLog\")\n if campaignLog then\n spawnData.position = campaignLog.getPosition()\n campaignLog.destruct()\n end\n end\n\n spawnObjectData(spawnData)\n end\n\n chaosBagApi.setChaosBagState(importData[\"bag\"])\n\n -- populate trauma values\n if importData[\"trauma\"] then\n setTrauma(importData[\"trauma\"])\n end\n\n -- populate ArkhamDB deck IDs\n if importData[\"decks\"] then\n deckImporterApi.setUiState(importData[\"decks\"])\n end\n\n -- maybe set campaign guide page\n if importData[\"guide\"] then\n local campaignGuide = findUniqueObjectWithTag(\"CampaignGuide\")\n if campaignGuide then\n Wait.condition(\n -- Called after the condition function returns true\n function() printToAll(\"Campaign Guide import successful!\") end,\n -- Condition function that is called continuously until it returns true or timeout is reached\n function() return campaignGuide.Book.setPage(importData[\"guide\"]) end,\n -- Amount of time in seconds until the Wait times out\n 2,\n -- Called if the Wait times out\n function() printToAll(\"Campaign Guide import failed!\") end\n )\n end\n end\n\n Wait.time(function() optionPanelApi.loadSettings(importData[\"options\"]) end, 0.5)\n\n -- destroy Tour Starter token\n local tourStarter = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"TourStarter\")\n if tourStarter then\n tourStarter.destruct()\n end\n\n -- restore PlayArea image and player count\n playAreaApi.updateSurface(importData[\"playarea\"])\n playAreaApi.setInvestigatorCount(importData[\"clueCount\"])\n\n coin.destruct()\n broadcastToAll(\"Campaign successfully imported!\", \"Green\")\nend\n\n-- creates a campaign token with save data encoded into GM Notes based on the current state of the table\nfunction createCampaignToken(_, playerColor, _)\n local campaignData = {}\n\n -- need to reset the contained objects to support multiple exports\n campaignTokenData.ContainedObjects = {}\n\n -- find active campaign\n local campaignBox\n for _, obj in ipairs(getObjectsWithTag(\"CampaignBox\")) do\n if obj.type == \"Bag\" and #obj.getObjects() == 0 then\n if not campaignBox then\n campaignBox = obj\n else\n broadcastToAll(\"Multiple empty campaign boxes detected; delete all but one.\", \"Red\")\n return\n end\n end\n end\n\n if not campaignBox then\n broadcastToAll(\"Campaign box with all placed objects not found!\", \"Red\")\n return\n end\n\n -- clean up chaos tokens (needs to happen before saving chaos bag state)\n blessCurseApi.removeAll(playerColor)\n chaosBagApi.releaseAllSealedTokens(playerColor)\n\n -- main data collection\n campaignData.box = campaignBox.getGUID()\n campaignData.bag = chaosBagApi.getChaosBagState()\n campaignData.decks = deckImporterApi.getUiState()\n campaignData.clueCount = playAreaApi.getInvestigatorCount()\n campaignData.playarea = playAreaApi.getSurface()\n campaignData.options = optionPanelApi.getOptions()\n\n -- save campaign log if present\n local campaignLog = findUniqueObjectWithTag(\"CampaignLog\")\n if campaignLog then\n local logData = campaignLog.getData()\n logData.Locked = false\n table.insert(campaignTokenData.ContainedObjects, logData)\n\n -- maybe also extract the trauma values\n local trauma = campaignLog.getVar(\"returnTrauma\")\n if trauma then\n printToAll(\"Trauma values found in campaign log!\", \"Green\")\n campaignData.trauma = {}\n for _, val in ipairs(campaignLog.call(\"returnTrauma\")) do\n table.insert(campaignData.trauma, val)\n end\n else\n printToAll(\"Trauma values could not be found in campaign log!\", \"Yellow\")\n end\n end\n\n -- store campaign guide page if present\n local campaignGuide = findUniqueObjectWithTag(\"CampaignGuide\")\n if campaignGuide then\n campaignData.guide = campaignGuide.Book.getPage()\n end\n\n -- store the additional index if there are any cards in it\n local additionalIndex = guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"AdditionalPlayerCardsBag\")\n if additionalIndex and #additionalIndex.getObjects() \u003e 0 then\n local indexData = additionalIndex.getData()\n indexData.Locked = false\n table.insert(campaignTokenData.ContainedObjects, indexData)\n end\n\n -- finish the data for the campaign token\n campaignTokenData.GMNotes = JSON.encode(campaignData)\n campaignTokenData.Nickname = campaignBox.getName() .. os.date(\" %b %d\") .. \" Save\"\n\n spawnObjectData({ data = campaignTokenData })\n broadcastToAll(\"Campaign successfully exported! Save coin object to import on a different save.\", \"Green\")\nend\n\n---------------------------------------------------------\n-- helper functions\n---------------------------------------------------------\n\nfunction findUniqueObjectWithTag(tag)\n local objects = getObjectsWithTag(tag)\n if not objects then return end\n\n if #objects == 1 then\n return objects[1]\n elseif #objects == 0 then\n broadcastToAll(\"No \" .. tag .. \" detected; ensure it has the correct tag.\", \"Red\")\n else\n broadcastToAll(\"More than one \" .. tag .. \" detected; delete all but one.\", \"Red\")\n end\nend\n\nfunction setTrauma(trauma)\n for i, matColor in ipairs({ \"White\", \"Orange\", \"Green\", \"Red\" }) do\n playmatApi.updateCounter(matColor, \"DamageCounter\", trauma[i])\n playmatApi.updateCounter(matColor, \"HorrorCounter\", trauma[i + 4])\n end\nend\nend)\n__bundle_register(\"arkhamdb/DeckImporterApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local DeckImporterApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getDeckImporter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"DeckImporter\")\n end\n\n ---@class uiStateTable\n ---@field redDeck string Deck ID to load for the red player\n ---@field orangeDeck string Deck ID to load for the orange player\n ---@field whiteDeck string Deck ID to load for the white player\n ---@field greenDeck string Deck ID to load for the green player\n ---@field privateDeck boolean True to load a private deck, false to load a public deck\n ---@field loadNewest boolean True if the most upgraded version of the deck should be loaded\n ---@field investigators boolean True if investigator cards should be spawned\n\n -- Returns a table with the full state of the UI, including options and deck IDs.\n -- This can be used to persist via onSave(), or provide values for a load operation\n ---@return uiStateTable uiStateTable Contains data about the current UI state\n DeckImporterApi.getUiState = function()\n local passthroughTable = {}\n for k,v in pairs(getDeckImporter().call(\"getUiState\")) do\n passthroughTable[k] = v\n end\n return passthroughTable\n end\n\n -- Updates the state of the UI based on the provided table. Any values not provided will be left the same.\n ---@return uiStateTable uiStateTable Contains data about the current UI state\n DeckImporterApi.setUiState = function(uiStateTable)\n return getDeckImporter().call(\"setUiState\", uiStateTable)\n end\n\n return DeckImporterApi\nend\nend)\n__bundle_register(\"chaosbag/BlessCurseManagerApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local BlessCurseManagerApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getManager()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"BlessCurseManager\")\n end\n\n -- removes all taken tokens and resets the counts\n BlessCurseManagerApi.removeTakenTokensAndReset = function()\n local BlessCurseManager = getManager()\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Bless\") end, 0.05)\n Wait.time(function() BlessCurseManager.call(\"removeTakenTokens\", \"Curse\") end, 0.10)\n Wait.time(function() BlessCurseManager.call(\"doReset\", \"White\") end, 0.15)\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.sealedToken = function(type, guid)\n getManager().call(\"sealedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.releasedToken = function(type, guid)\n getManager().call(\"releasedToken\", { type = type, guid = guid })\n end\n\n -- updates the internal count (called by cards that seal bless/curse tokens)\n ---@param type string Type of chaos token (\"Bless\" or \"Curse\")\n ---@param guid string GUID of the token\n BlessCurseManagerApi.returnedToken = function(type, guid)\n getManager().call(\"returnedToken\", { type = type, guid = guid })\n end\n\n -- broadcasts the current status for bless/curse tokens\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.broadcastStatus = function(playerColor)\n getManager().call(\"broadcastStatus\", playerColor)\n end\n\n -- removes all bless / curse tokens from the chaos bag and play\n ---@param playerColor string Color of the player to show the broadcast to\n BlessCurseManagerApi.removeAll = function(playerColor)\n getManager().call(\"doRemove\", playerColor)\n end\n\n -- adds bless / curse sealing to the hovered card\n ---@param playerColor string Color of the player to show the broadcast to\n ---@param hoveredObject tts__Object Hovered object\n BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)\n getManager().call(\"addMenuOptions\", { playerColor = playerColor, hoveredObject = hoveredObject })\n end\n \n return BlessCurseManagerApi\nend\nend)\n__bundle_register(\"playermat/PlaymatApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlaymatApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n local searchLib = require(\"util/SearchLib\")\n\n -- Convenience function to look up a mat's object by color, or get all mats.\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@return table: Single-element if only single playmat is requested\n local function getMatForColor(matColor)\n if matColor == \"All\" then\n return guidReferenceApi.getObjectsByType(\"Playermat\")\n else\n return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, \"Playermat\") }\n end\n end\n\n -- Returns the color of the closest playmat\n ---@param startPos table Starting position to get the closest mat from\n PlaymatApi.getMatColorByPosition = function(startPos)\n local result, smallestDistance\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local distance = Vector.between(startPos, mat.getPosition()):magnitude()\n if smallestDistance == nil or distance \u003c smallestDistance then\n smallestDistance = distance\n result = matColor\n end\n end\n return result\n end\n\n -- Returns the color of the player's hand that is seated next to the playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getPlayerColor = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"playerColor\")\n end\n end\n\n -- Returns the color of the playmat that owns the playercolor's hand\n ---@param handColor string Color of the playmat\n PlaymatApi.getMatColor = function(handColor)\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local playerColor = mat.getVar(\"playerColor\")\n if playerColor == handColor then\n return matColor\n end\n end\n end\n\n -- Returns if there is the card \"Dream-Enhancing Serum\" on the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.isDES = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"isDES\")\n end\n end\n\n -- Performs a search of the deck area of the requested playmat and returns the result as table\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDeckAreaObjects = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getDeckAreaObjects\")\n end\n end\n\n -- Flips the top card of the deck (useful after deck manipulation for Norman Withers)\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.flipTopCardFromDeck = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"flipTopCardFromDeck\")\n end\n end\n\n -- Returns the position of the discard pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDiscardPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDiscardPosition\")\n end\n end\n\n -- Returns the position of the draw pile of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.getDrawPosition = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"returnGlobalDrawPosition\")\n end\n end\n\n -- Transforms a local position into a global position\n ---@param localPos table Local position to be transformed\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.transformLocalPosition = function(localPos, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.positionToWorld(localPos)\n end\n end\n\n -- Returns the rotation of the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnRotation = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getRotation()\n end\n end\n\n -- Returns a table with spawn data (position and rotation) for a helper object\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param helperName string Name of the helper object\n PlaymatApi.getHelperSpawnData = function(matColor, helperName)\n local resultTable = {}\n local localPositionTable = {\n [\"Hand Helper\"] = {0.05, 0, -1.182},\n [\"Search Assistant\"] = {-0.3, 0, -1.182}\n }\n \n for color, mat in pairs(getMatForColor(matColor)) do\n resultTable[color] = {\n position = mat.positionToWorld(localPositionTable[helperName]),\n rotation = mat.getRotation()\n }\n end\n return resultTable\n end\n\n\n -- Triggers the Upkeep for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param playerColor string Color of the calling player (for messages)\n PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doUpkeepFromHotkey\", playerColor)\n end\n end\n\n -- Handles discarding for the requested playmat for the provided list of objects\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param objList table List of objects to discard\n PlaymatApi.discardListOfObjects = function(matColor, objList)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"discardListOfObjects\", objList)\n end\n end\n\n -- Returns the active investigator id\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n PlaymatApi.returnInvestigatorId = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.getVar(\"activeInvestigatorId\")\n end\n end\n\n -- Returns the position for encounter card drawing\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param stack boolean If true, returns the leftmost position instead of the first empty from the right\n PlaymatApi.getEncounterCardDrawPosition = function(matColor, stack)\n for _, mat in pairs(getMatForColor(matColor)) do\n return Vector(mat.call(\"getEncounterCardDrawPosition\", stack))\n end\n end\n\n -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If\n -- matchTypes is true, the main card slot snap points will only snap assets, while the\n -- investigator area point will only snap Investigators. If matchTypes is false, snap points will\n -- be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"setLimitSnapsByType\", matchCardTypes)\n end\n end\n\n -- Sets the requested playmat's draw 1 button to visible\n ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"showDrawButton\", isDrawButtonVisible)\n end\n end\n\n -- Shows or hides the clickable clue counter for the requested playmat\n ---@param showCounter boolean Whether the clickable counter should be present or not\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.clickableClues = function(showCounter, matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"clickableClues\", showCounter)\n end\n end\n\n -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.removeClues = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"removeClues\")\n end\n end\n\n -- Reports the clue count for the requested playmat\n ---@param useClickableCounters boolean Controls which type of counter is getting checked\n PlaymatApi.getClueCount = function(useClickableCounters, matColor)\n local count = 0\n for _, mat in pairs(getMatForColor(matColor)) do\n count = count + mat.call(\"getClueCount\", useClickableCounters)\n end\n return count\n end\n\n -- Updates the specified owned counter\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param type string Counter to target\n ---@param newValue number Value to set the counter to\n ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier\n PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"updateCounter\", { type = type, newValue = newValue, modifier = modifier })\n end\n end\n\n -- Triggers the draw function for the specified playmat\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param number number Amount of cards to draw\n PlaymatApi.drawCardsWithReshuffle = function(matColor, number)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"drawCardsWithReshuffle\", number)\n end\n end\n\n -- Returns the resource counter amount\n ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support \"All\")\n ---@param type string Counter to target\n PlaymatApi.getCounterValue = function(matColor, type)\n for _, mat in pairs(getMatForColor(matColor)) do\n return mat.call(\"getCounterValue\", type)\n end\n end\n\n -- Returns a list of mat colors that have an investigator placed\n PlaymatApi.getUsedMatColors = function()\n local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }\n local usedColors = {}\n for matColor, mat in pairs(getMatForColor(\"All\")) do\n local searchPos = mat.positionToWorld(localInvestigatorPosition)\n local searchResult = searchLib.atPosition(searchPos, \"isCardOrDeck\")\n if #searchResult \u003e 0 then\n table.insert(usedColors, matColor)\n end\n end\n return usedColors\n end\n\n -- Resets the specified skill tracker to \"1, 1, 1, 1\"\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.resetSkillTracker = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"resetSkillTracker\")\n end\n end\n\n -- Finds all objects on the playmat and associated set aside zone and returns a table\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n ---@param filter string Name of the filte function (see util/SearchLib)\n PlaymatApi.searchAroundPlaymat = function(matColor, filter)\n local objList = {}\n for _, mat in pairs(getMatForColor(matColor)) do\n for _, obj in ipairs(mat.call(\"searchAroundSelf\", filter)) do\n table.insert(objList, obj)\n end\n end\n return objList\n end\n\n -- Discard a non-hidden card from the corresponding player's hand\n ---@param matColor string Color of the playmat - White, Orange, Green, Red or All\n PlaymatApi.doDiscardOne = function(matColor)\n for _, mat in pairs(getMatForColor(matColor)) do\n mat.call(\"doDiscardOne\")\n end\n end\n\n -- Triggers the metadata sync for all playmats\n PlaymatApi.syncAllCustomizableCards = function()\n for _, mat in pairs(getMatForColor(\"All\")) do\n mat.call(\"syncAllCustomizableCards\")\n end\n end\n\n return PlaymatApi\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/CampaignImporterExporter\")\nend)\n__bundle_register(\"core/OptionPanelApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local OptionPanelApi = {}\n\n -- loads saved options\n ---@param options table Set a new state for the option table\n OptionPanelApi.loadSettings = function(options)\n return Global.call(\"loadSettings\", options)\n end\n\n ---@return any: Table of option panel state\n OptionPanelApi.getOptions = function()\n return Global.getTable(\"optionPanel\")\n end\n\n return OptionPanelApi\nend\nend)\n__bundle_register(\"core/PlayAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local PlayAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getPlayArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"PlayArea\")\n end\n\n local function getInvestigatorCounter()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"InvestigatorCounter\")\n end\n\n -- Returns the current value of the investigator counter from the playmat\n ---@return number: Number of investigators currently set on the counter\n PlayAreaApi.getInvestigatorCount = function()\n return getInvestigatorCounter().getVar(\"val\")\n end\n\n -- Updates the current value of the investigator counter from the playmat\n ---@param count number Number of investigators to set on the counter\n PlayAreaApi.setInvestigatorCount = function(count)\n getInvestigatorCounter().call(\"updateVal\", count)\n end\n\n -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain\n -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'\n ---@param playerColor string Color of the player requesting the shift for messages\n PlayAreaApi.shiftContentsUp = function(playerColor)\n getPlayArea().call(\"shiftContentsUp\", playerColor)\n end\n\n PlayAreaApi.shiftContentsDown = function(playerColor)\n getPlayArea().call(\"shiftContentsDown\", playerColor)\n end\n\n PlayAreaApi.shiftContentsLeft = function(playerColor)\n getPlayArea().call(\"shiftContentsLeft\", playerColor)\n end\n\n PlayAreaApi.shiftContentsRight = function(playerColor)\n getPlayArea().call(\"shiftContentsRight\", playerColor)\n end\n\n ---@param state boolean This controls whether location connections should be drawn\n PlayAreaApi.setConnectionDrawState = function(state)\n getPlayArea().call(\"setConnectionDrawState\", state)\n end\n\n ---@param color string Connection color to be used for location connections\n PlayAreaApi.setConnectionColor = function(color)\n getPlayArea().call(\"setConnectionColor\", color)\n end\n\n -- Event to be called when the current scenario has changed\n ---@param scenarioName string Name of the new scenario\n PlayAreaApi.onScenarioChanged = function(scenarioName)\n getPlayArea().call(\"onScenarioChanged\", scenarioName)\n end\n\n -- Sets this playmat's snap points to limit snapping to locations or not.\n -- If matchTypes is false, snap points will be reset to snap all cards.\n ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types\n PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)\n getPlayArea().call(\"setLimitSnapsByType\", matchCardTypes)\n end\n\n -- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged\n -- cards before they're destroyed by entering the container\n PlayAreaApi.tryObjectEnterContainer = function(container, object)\n getPlayArea().call(\"tryObjectEnterContainer\", { container = container, object = object })\n end\n\n -- Counts the VP on locations in the play area\n PlayAreaApi.countVP = function()\n return getPlayArea().call(\"countVP\")\n end\n\n -- Highlights all locations in the play area without metadata\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightMissingData = function(state)\n return getPlayArea().call(\"highlightMissingData\", state)\n end\n\n -- Highlights all locations in the play area with VP\n ---@param state boolean True if highlighting should be enabled\n PlayAreaApi.highlightCountedVP = function(state)\n return getPlayArea().call(\"countVP\", state)\n end\n\n -- Checks if an object is in the play area (returns true or false)\n PlayAreaApi.isInPlayArea = function(object)\n return getPlayArea().call(\"isInPlayArea\", object)\n end\n\n -- Returns the current surface of the play area\n PlayAreaApi.getSurface = function()\n return getPlayArea().getCustomObject().image\n end\n\n -- Updates the surface of the play area\n PlayAreaApi.updateSurface = function(url)\n return getPlayArea().call(\"updateSurface\", url)\n end\n\n -- Returns a deep copy of the currently tracked locations\n PlayAreaApi.getTrackedLocations = function()\n local t = {}\n for k, v in pairs(getPlayArea().call(\"getTrackedLocations\")) do\n t[k] = v\n end\n return t\n end\n\n -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the\n -- data to the local token manager instance.\n ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call\n PlayAreaApi.updateLocations = function(args)\n getPlayArea().call(\"updateLocations\", args)\n end\n\n PlayAreaApi.getCustomDataHelper = function()\n return getPlayArea().getVar(\"customDataHelper\")\n end\n\n return PlayAreaApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Tile", @@ -205645,7 +208862,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/TokenArranger\")\nend)\n__bundle_register(\"accessories/TokenArranger\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\n\n-- common parameters\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.label = \"\"\nbuttonParameters.tooltip = \"Increase / Decrease\"\nbuttonParameters.color = { 0, 0, 0, 0 }\nbuttonParameters.width = 325\nbuttonParameters.height = 325\n\nlocal inputParameters = {}\ninputParameters.function_owner = self\ninputParameters.font_size = 100\ninputParameters.width = 250\ninputParameters.height = inputParameters.font_size + 23\ninputParameters.alignment = 3\ninputParameters.validation = 2\ninputParameters.tab = 2\n\nlocal percentageLabel = {}\npercentageLabel.function_owner = self\npercentageLabel.click_function = \"none\"\npercentageLabel.width = 0\npercentageLabel.height = 0\n\n-- variables with save function\nlocal tokenPrecedence = {}\nlocal percentage = false\nlocal includeDrawnTokens = true\n\n-- variables without save function\nlocal updating = false\nlocal TOKEN_NAMES = {\n \"Elder Sign\",\n \"Skull\",\n \"Cultist\",\n \"Tablet\",\n \"Elder Thing\",\n \"Auto-fail\",\n \"Bless\",\n \"Curse\",\n \"Frost\",\n \"\"\n}\n\n-- saving the precedence settings and information on the most recently loaded data\nfunction onSave()\n return JSON.encode({\n tokenPrecedence = tokenPrecedence,\n percentage = percentage,\n includeDrawnTokens = includeDrawnTokens\n })\nend\n\n-- loading data, button creation and initial layouting\nfunction onLoad(saveState)\n if saveState ~= nil and saveState ~= \"\" then\n local loadedData = JSON.decode(saveState)\n tokenPrecedence = loadedData.tokenPrecedence\n percentage = loadedData.percentage\n includeDrawnTokens = loadedData.includeDrawnTokens\n else\n loadDefaultValues()\n\n -- grab token metadata from mythos area\n Wait.time(function() onTokenDataChanged(mythosAreaApi.returnTokenData()) end, 0.2)\n end\n\n createButtonsAndInputs()\n \n -- maybe trigger layout() to draw percentage buttons\n local objList = getObjectsWithTag(\"tempToken\")\n if #objList \u003e 0 then\n Wait.time(layout, 0.5)\n end\n \n -- context menu items\n self.addContextMenuItem(\"Load default values\", function()\n loadDefaultValues()\n updateUI()\n layout()\n end)\n\n self.addContextMenuItem(\"Include drawn tokens\", function()\n includeDrawnTokens = not includeDrawnTokens\n local text = includeDrawnTokens and \" \" or \" not \"\n broadcastToAll(\"Token Arranger will\" .. text .. \"include currently drawn chaos tokens.\", \"Orange\")\n layout()\n end)\n\n self.addContextMenuItem(\"Toggle percentages\", function()\n if percentage then\n percentage = false\n else\n percentage = \"basic\"\n broadcastToAll(\"Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).\", \"Yellow\")\n end\n layout()\n end)\n\n self.addContextMenuItem(\"Toggle cumulative\", function()\n if percentage == \"cumulative\" then\n percentage = \"basic\"\n else\n percentage = \"cumulative\"\n end\n broadcastToAll(\"Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).\", \"Yellow\")\n layout()\n end)\nend\n\n-- delete temporary tokens when destroyed\nfunction onDestroy() deleteCopiedTokens() end\n\n-- layout tokens when dropped (after 1.5 seconds)\nfunction onDrop() Wait.time(layout, 1.5) end\n\n-- delete temporary tokens when picked up\nfunction onPickUp() deleteCopiedTokens() end\n\n-- click_function for buttons on chaos tokens\nfunction tokenClick(isRightClick, index)\n local change = tonumber(isRightClick and \"-1\" or \"1\")\n tokenPrecedence[TOKEN_NAMES[index]][1] = tokenPrecedence[TOKEN_NAMES[index]][1] + change\n self.editInput({\n index = index - 1,\n value = tokenPrecedence[TOKEN_NAMES[index]][1]\n })\n layout()\nend\n\n-- input_function for input_boxes\nfunction tokenInput(input, selected, index)\n if selected == false then\n local num = tonumber(input)\n if num ~= nil then\n tokenPrecedence[TOKEN_NAMES[index]][1] = num\n end\n layout()\n end\nend\n\n-- loads the default precedence table\nfunction loadDefaultValues()\n -- 1st value: token modifiers for sorting\n -- 2nd value: order for equivalent tokens (starts at 2 because of \"+1\" token)\n tokenPrecedence = {\n [\"Elder Sign\"] = { 100, 2},\n [\"Skull\"] = { -1, 3},\n [\"Cultist\"] = { -2, 4},\n [\"Tablet\"] = { -3, 5},\n [\"Elder Thing\"] = { -4, 6},\n [\"Auto-fail\"] = { -100, 7},\n [\"Bless\"] = { 101, 8},\n [\"Curse\"] = { -101, 9},\n [\"Frost\"] = { -99, 10},\n [\"\"] = { 0, 11}\n }\nend\n\n-- creates buttons and inputs\nfunction createButtonsAndInputs()\n local offset = 0.725\n local pos = { x = { -1.067, 0.377 }, z = -2.175 }\n\n -- button and inputs index 0-9\n for i = 1, 10 do\n if i \u003c 6 then\n buttonParameters.position = { pos.x[1], 0, pos.z + i * offset }\n inputParameters.position = { pos.x[1] + offset, 0.1, pos.z + i * offset }\n else\n buttonParameters.position = { pos.x[2], 0, pos.z + (i - 5) * offset }\n inputParameters.position = { pos.x[2] + offset, 0.1, pos.z + (i - 5) * offset }\n end\n\n buttonParameters.click_function = \"tokenClick\" .. i\n inputParameters.input_function = \"tokenInput\" .. i\n inputParameters.value = tokenPrecedence[TOKEN_NAMES[i]][1]\n\n -- setting click-/inputfunction\n self.setVar(buttonParameters.click_function, function(_, _, isRightClick) tokenClick(isRightClick, i) end)\n self.setVar(inputParameters.input_function, function(_, _, input, selected) tokenInput(input, selected, i) end)\n\n -- button/input creation\n self.createButton(buttonParameters)\n self.createInput(inputParameters)\n end\n\n -- index 10: \"Update / Hide\" button\n self.createButton({\n function_owner = self,\n label = \"Update / Hide\",\n click_function = \"layout\",\n tooltip = \"Left-Click: Update!\\nRight-Click: Hide Tokens!\",\n position = { 0.725, 0.1, 2.025 },\n color = { 1, 1, 1 },\n width = 675,\n height = 175\n })\nend\n\n-- update input fields\nfunction updateUI()\n for i = 1, 10 do\n self.editInput({\n index = i - 1,\n value = tokenPrecedence[TOKEN_NAMES[i]][1]\n })\n end\nend\n\n-- order function for data sorting\nfunction tokenValueComparator(left, right)\n if left.value ~= right.value then\n return left.value \u003e right.value\n elseif left.order ~= right.order then\n return left.order \u003c right.order\n else\n return false\n end\nend\n\n-- deletes previously placed tokens\nfunction deleteCopiedTokens()\n for _, token in ipairs(getObjectsWithTag(\"tempToken\")) do\n token.destruct()\n end\n\n -- this removes the percentage buttons (by index 11+)\n local buttonCount = #self.getButtons()\n if buttonCount \u003c 12 then return end\n\n for i = buttonCount, 12, -1 do\n self.removeButton(i - 1)\n end\nend\n\n-- creates buttons as labels as display for percentage values\nfunction createPercentageButton(tokenCount, valueCount, tokenName)\n local startPos = Vector(2.3, -0.04, 0.875 * valueCount)\n\n if percentage == \"cumulative\" then\n percentageLabel.scale = { 1.5, 1.5, 1.5 }\n percentageLabel.position = startPos - Vector(0, 0, 2.85)\n else\n percentageLabel.scale = { 2, 2, 2 }\n percentageLabel.position = startPos - Vector(0, 0, 2.675)\n end\n\n -- determine font_color\n if tokenName == \"Elder Sign\" then\n percentageLabel.font_color = { 0.35, 0.71, 0.85 }\n elseif tokenName == \"Auto-fail\" then\n percentageLabel.font_color = { 0.86, 0.1, 0.1 }\n -- check if the tokenName contains letters (e.g. symbol token)\n elseif string.match(tokenName, \"%a\") ~= nil then\n percentageLabel.font_color = { 0.68, 0.53, 0.86 }\n else\n percentageLabel.font_color = { 0.85, 0.67, 0.33 }\n end\n\n -- create label for base percentage\n local basePercentage = math.floor((tokenCount.row / tokenCount.total) * 10000) / 100\n percentageLabel.label = string.format(\"%s\", string.format(\"%05.2f\", basePercentage) .. \"%\")\n self.createButton(percentageLabel)\n\n -- optionally create label for cumulative percentage\n if percentage == \"cumulative\" then\n percentageLabel.position = startPos - Vector(0, 0, 2.45)\n percentageLabel.font_color = { 1, 1, 1 }\n\n -- only display one digit for 100%\n if tokenCount.sum == tokenCount.total then\n percentageLabel.label = \"100.0%\"\n else\n local cumulativePercentage = math.floor((tokenCount.sum / tokenCount.total) * 10000) / 100\n percentageLabel.label = string.format(\"%s\", string.format(\"%05.2f\", cumulativePercentage) .. \"%\")\n end\n self.createButton(percentageLabel)\n end\nend\n\n-- main function (delete old tokens, clone chaos bag content, sort it and position it)\nfunction layout(_, _, isRightClick)\n if updating then return end\n updating = true\n deleteCopiedTokens()\n\n -- stop here if right-clicked\n if isRightClick then\n updating = false\n return\n end\n\n -- get ChaosBag and stop if not found\n local chaosBag = chaosBagApi.findChaosBag()\n if not chaosBag then\n updating = false\n return\n end\n\n -- clone tokens from chaos bag (default position above trash can)\n local rawData = chaosBag.getData().ContainedObjects\n\n -- optionally get the data for tokens in play\n if includeDrawnTokens then\n for _, token in pairs(chaosBagApi.getTokensInPlay()) do\n if token ~= nil then table.insert(rawData, token.getData()) end\n end\n end\n\n -- generate layout data\n local data = {}\n for i, objData in ipairs(rawData) do\n objData[\"Tags\"] = { \"tempToken\" }\n local value = tonumber(objData.Nickname)\n local precedence = tokenPrecedence[objData.Nickname]\n\n -- remove GUID to avoid issues for high latency clients\n objData[\"GUID\"] = nil\n\n -- store data with value / precendence\n data[i] = {\n token = objData,\n value = value or precedence[1]\n }\n\n -- order for comparator function\n if precedence ~= nil then\n data[i].order = precedence[2]\n else\n data[i].order = value\n end\n end\n\n -- sort table by value (symbols last if same value)\n table.sort(data, tokenValueComparator)\n\n -- laying out the tokens\n local pos = self.getPosition() + Vector(3.55, -0.05, -3.95)\n if percentage then pos.z = pos.z - 3.05 end\n\n local location = { x = pos.x, y = pos.y, z = pos.z }\n local rotation = self.getRotation()\n local currentValue = data[1].value\n local tokenCount = { row = 0, sum = 0, total = #data }\n local valueCount = 1\n local tokenName = false\n\n for i, item in ipairs(data) do\n -- this is true for the first token in a new row\n if item.value ~= currentValue then\n if percentage then\n tokenCount.sum = tokenCount.sum + tokenCount.row\n createPercentageButton(tokenCount, valueCount, tokenName)\n end\n\n location.x = location.x - 1.75\n location.z = pos.z\n currentValue = item.value\n valueCount = valueCount + 1\n tokenCount.row = 0\n end\n\n spawnObjectData({\n data = item.token,\n position = location,\n rotation = rotation\n })\n tokenName = item.token.Nickname\n location.z = location.z - 1.75\n tokenCount.row = tokenCount.row + 1\n end\n\n -- this is repeated to create the button for the last token\n if percentage then\n tokenCount.sum = tokenCount.sum + tokenCount.row\n createPercentageButton(tokenCount, valueCount, tokenName)\n end\n\n -- introducing a small delay to limit update calls\n Wait.time(function() updating = false end, 0.1)\nend\n\n-- called from outside to set default values for tokens\nfunction onTokenDataChanged(parameters)\n local tokenData = parameters.tokenData or {}\n local currentScenario = parameters.currentScenario or \"\"\n local useFrontData = parameters.useFrontData\n\n -- update token precedence\n for key, table in pairs(tokenData) do\n local modifier = table.modifier\n if modifier == -999 then modifier = 0 end\n tokenPrecedence[key][1] = modifier\n end\n\n updateUI()\n layout()\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat\n ---@param mat tts__Object Playermat that triggered this\n ---@param alwaysFaceUp boolean Whether the card should be drawn face-up\n MythosAreaApi.drawEncounterCard = function(mat, alwaysFaceUp)\n getMythosArea().call(\"drawEncounterCard\", {mat = mat, alwaysFaceUp = alwaysFaceUp})\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"core/GUIDReferenceApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local GUIDReferenceApi = {}\n\n local function getGuidHandler()\n return getObjectFromGUID(\"123456\")\n end\n\n -- Returns the matching object\n ---@param owner string Parent object for this search\n ---@param type string Type of object to search for\n ---@return any: Object reference to the matching object\n GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)\n return getGuidHandler().call(\"getObjectByOwnerAndType\", { owner = owner, type = type })\n end\n\n -- Returns all matching objects as a table with references\n ---@param type string Type of object to search for\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByType = function(type)\n return getGuidHandler().call(\"getObjectsByType\", type)\n end\n\n -- Returns all matching objects as a table with references\n ---@param owner string Parent object for this search\n ---@return table: List of object references to matching objects\n GUIDReferenceApi.getObjectsByOwner = function(owner)\n return getGuidHandler().call(\"getObjectsByOwner\", owner)\n end\n\n -- Sends new information to the reference handler to edit the main index\n ---@param owner string Parent of the object\n ---@param type string Type of the object\n ---@param guid string GUID of the object\n GUIDReferenceApi.editIndex = function(owner, type, guid)\n return getGuidHandler().call(\"editIndex\", {\n owner = owner,\n type = type,\n guid = guid\n })\n end\n\n -- Returns the owner of an object or the object it's located on\n ---@param object tts__GameObject Object for this search\n ---@return string: Parent of the object or object it's located on\n GUIDReferenceApi.getOwnerOfObject = function(object)\n return getGuidHandler().call(\"getOwnerOfObject\", object)\n end\n\n return GUIDReferenceApi\nend\nend)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"accessories/TokenArranger\")\nend)\n__bundle_register(\"accessories/TokenArranger\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\nlocal mythosAreaApi = require(\"core/MythosAreaApi\")\n\n-- common parameters\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.label = \"\"\nbuttonParameters.tooltip = \"Increase / Decrease\"\nbuttonParameters.color = { 0, 0, 0, 0 }\nbuttonParameters.width = 325\nbuttonParameters.height = 325\n\nlocal inputParameters = {}\ninputParameters.function_owner = self\ninputParameters.font_size = 100\ninputParameters.width = 250\ninputParameters.height = inputParameters.font_size + 23\ninputParameters.alignment = 3\ninputParameters.validation = 2\ninputParameters.tab = 2\n\nlocal percentageLabel = {}\npercentageLabel.function_owner = self\npercentageLabel.click_function = \"none\"\npercentageLabel.width = 0\npercentageLabel.height = 0\n\n-- variables with save function\nlocal tokenPrecedence = {}\nlocal percentage = false\nlocal includeDrawnTokens = true\n\n-- variables without save function\nlocal updating = false\nlocal TOKEN_NAMES = {\n \"Elder Sign\",\n \"Skull\",\n \"Cultist\",\n \"Tablet\",\n \"Elder Thing\",\n \"Auto-fail\",\n \"Bless\",\n \"Curse\",\n \"Frost\",\n \"\"\n}\n\n-- saving the precedence settings and information on the most recently loaded data\nfunction onSave()\n return JSON.encode({\n tokenPrecedence = tokenPrecedence,\n percentage = percentage,\n includeDrawnTokens = includeDrawnTokens\n })\nend\n\n-- loading data, button creation and initial layouting\nfunction onLoad(savedData)\n if savedData and savedData ~= \"\" then\n local loadedData = JSON.decode(savedData)\n tokenPrecedence = loadedData.tokenPrecedence\n percentage = loadedData.percentage\n includeDrawnTokens = loadedData.includeDrawnTokens\n else\n loadDefaultValues()\n\n -- grab token metadata from mythos area\n Wait.time(function() onTokenDataChanged(mythosAreaApi.returnTokenData()) end, 0.2)\n end\n\n createButtonsAndInputs()\n \n -- maybe trigger layout() to draw percentage buttons\n local objList = getObjectsWithTag(\"tempToken\")\n if #objList \u003e 0 then\n Wait.time(layout, 0.5)\n end\n \n -- context menu items\n self.addContextMenuItem(\"Load default values\", function()\n loadDefaultValues()\n updateUI()\n layout()\n end)\n\n self.addContextMenuItem(\"Include drawn tokens\", function()\n includeDrawnTokens = not includeDrawnTokens\n local text = includeDrawnTokens and \" \" or \" not \"\n broadcastToAll(\"Token Arranger will\" .. text .. \"include currently drawn chaos tokens.\", \"Orange\")\n layout()\n end)\n\n self.addContextMenuItem(\"Toggle percentages\", function()\n if percentage then\n percentage = false\n else\n percentage = \"basic\"\n broadcastToAll(\"Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).\", \"Yellow\")\n end\n layout()\n end)\n\n self.addContextMenuItem(\"Toggle cumulative\", function()\n if percentage == \"cumulative\" then\n percentage = \"basic\"\n else\n percentage = \"cumulative\"\n end\n broadcastToAll(\"Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).\", \"Yellow\")\n layout()\n end)\nend\n\n-- delete temporary tokens when destroyed\nfunction onDestroy() deleteCopiedTokens() end\n\n-- layout tokens when dropped (after 1.5 seconds)\nfunction onDrop() Wait.time(layout, 1.5) end\n\n-- delete temporary tokens when picked up\nfunction onPickUp() deleteCopiedTokens() end\n\n-- click_function for buttons on chaos tokens\nfunction tokenClick(isRightClick, index)\n local change = tonumber(isRightClick and \"-1\" or \"1\")\n tokenPrecedence[TOKEN_NAMES[index]][1] = tokenPrecedence[TOKEN_NAMES[index]][1] + change\n self.editInput({\n index = index - 1,\n value = tokenPrecedence[TOKEN_NAMES[index]][1]\n })\n layout()\nend\n\n-- input_function for input_boxes\nfunction tokenInput(input, selected, index)\n if selected == false then\n local num = tonumber(input)\n if num ~= nil then\n tokenPrecedence[TOKEN_NAMES[index]][1] = num\n end\n layout()\n end\nend\n\n-- loads the default precedence table\nfunction loadDefaultValues()\n -- 1st value: token modifiers for sorting\n -- 2nd value: order for equivalent tokens (starts at 2 because of \"+1\" token)\n tokenPrecedence = {\n [\"Elder Sign\"] = { 100, 2},\n [\"Skull\"] = { -1, 3},\n [\"Cultist\"] = { -2, 4},\n [\"Tablet\"] = { -3, 5},\n [\"Elder Thing\"] = { -4, 6},\n [\"Auto-fail\"] = { -100, 7},\n [\"Bless\"] = { 101, 8},\n [\"Curse\"] = { -101, 9},\n [\"Frost\"] = { -99, 10},\n [\"\"] = { 0, 11}\n }\nend\n\n-- creates buttons and inputs\nfunction createButtonsAndInputs()\n local offset = 0.725\n local pos = { x = { -1.067, 0.377 }, z = -2.175 }\n\n -- button and inputs index 0-9\n for i = 1, 10 do\n if i \u003c 6 then\n buttonParameters.position = { pos.x[1], 0, pos.z + i * offset }\n inputParameters.position = { pos.x[1] + offset, 0.1, pos.z + i * offset }\n else\n buttonParameters.position = { pos.x[2], 0, pos.z + (i - 5) * offset }\n inputParameters.position = { pos.x[2] + offset, 0.1, pos.z + (i - 5) * offset }\n end\n\n buttonParameters.click_function = \"tokenClick\" .. i\n inputParameters.input_function = \"tokenInput\" .. i\n inputParameters.value = tokenPrecedence[TOKEN_NAMES[i]][1]\n\n -- setting click-/inputfunction\n self.setVar(buttonParameters.click_function, function(_, _, isRightClick) tokenClick(isRightClick, i) end)\n self.setVar(inputParameters.input_function, function(_, _, input, selected) tokenInput(input, selected, i) end)\n\n -- button/input creation\n self.createButton(buttonParameters)\n self.createInput(inputParameters)\n end\n\n -- index 10: \"Update / Hide\" button\n self.createButton({\n function_owner = self,\n label = \"Update / Hide\",\n click_function = \"layout\",\n tooltip = \"Left-Click: Update!\\nRight-Click: Hide Tokens!\",\n position = { 0.725, 0.1, 2.025 },\n color = { 1, 1, 1 },\n width = 675,\n height = 175\n })\nend\n\n-- update input fields\nfunction updateUI()\n for i = 1, 10 do\n self.editInput({\n index = i - 1,\n value = tokenPrecedence[TOKEN_NAMES[i]][1]\n })\n end\nend\n\n-- order function for data sorting\nfunction tokenValueComparator(left, right)\n if left.value ~= right.value then\n return left.value \u003e right.value\n elseif left.order ~= right.order then\n return left.order \u003c right.order\n else\n return false\n end\nend\n\n-- deletes previously placed tokens\nfunction deleteCopiedTokens()\n for _, token in ipairs(getObjectsWithTag(\"tempToken\")) do\n token.destruct()\n end\n\n -- this removes the percentage buttons (by index 11+)\n local buttonCount = #self.getButtons()\n if buttonCount \u003c 12 then return end\n\n for i = buttonCount, 12, -1 do\n self.removeButton(i - 1)\n end\nend\n\n-- creates buttons as labels as display for percentage values\nfunction createPercentageButton(tokenCount, valueCount, tokenName)\n local startPos = Vector(2.3, -0.04, 0.875 * valueCount)\n\n if percentage == \"cumulative\" then\n percentageLabel.scale = { 1.5, 1.5, 1.5 }\n percentageLabel.position = startPos - Vector(0, 0, 2.85)\n else\n percentageLabel.scale = { 2, 2, 2 }\n percentageLabel.position = startPos - Vector(0, 0, 2.675)\n end\n\n -- determine font_color\n if tokenName == \"Elder Sign\" then\n percentageLabel.font_color = { 0.35, 0.71, 0.85 }\n elseif tokenName == \"Auto-fail\" then\n percentageLabel.font_color = { 0.86, 0.1, 0.1 }\n -- check if the tokenName contains letters (e.g. symbol token)\n elseif string.match(tokenName, \"%a\") ~= nil then\n percentageLabel.font_color = { 0.68, 0.53, 0.86 }\n else\n percentageLabel.font_color = { 0.85, 0.67, 0.33 }\n end\n\n -- create label for base percentage\n local basePercentage = math.floor((tokenCount.row / tokenCount.total) * 10000) / 100\n percentageLabel.label = string.format(\"%s\", string.format(\"%05.2f\", basePercentage) .. \"%\")\n self.createButton(percentageLabel)\n\n -- optionally create label for cumulative percentage\n if percentage == \"cumulative\" then\n percentageLabel.position = startPos - Vector(0, 0, 2.45)\n percentageLabel.font_color = { 1, 1, 1 }\n\n -- only display one digit for 100%\n if tokenCount.sum == tokenCount.total then\n percentageLabel.label = \"100.0%\"\n else\n local cumulativePercentage = math.floor((tokenCount.sum / tokenCount.total) * 10000) / 100\n percentageLabel.label = string.format(\"%s\", string.format(\"%05.2f\", cumulativePercentage) .. \"%\")\n end\n self.createButton(percentageLabel)\n end\nend\n\n-- main function (delete old tokens, clone chaos bag content, sort it and position it)\nfunction layout(_, _, isRightClick)\n if updating then return end\n updating = true\n deleteCopiedTokens()\n\n -- stop here if right-clicked\n if isRightClick then\n updating = false\n return\n end\n\n -- get ChaosBag and stop if not found\n local chaosBag = chaosBagApi.findChaosBag()\n if not chaosBag then\n updating = false\n return\n end\n\n -- clone tokens from chaos bag (default position above trash can)\n local rawData = chaosBag.getData().ContainedObjects\n\n -- optionally get the data for tokens in play\n if includeDrawnTokens then\n for _, token in pairs(chaosBagApi.getTokensInPlay()) do\n if token ~= nil then table.insert(rawData, token.getData()) end\n end\n end\n\n -- generate layout data\n local data = {}\n for i, objData in ipairs(rawData) do\n objData[\"Tags\"] = { \"tempToken\" }\n local value = tonumber(objData.Nickname)\n local precedence = tokenPrecedence[objData.Nickname]\n\n -- remove GUID to avoid issues for high latency clients\n objData[\"GUID\"] = nil\n\n -- store data with value / precendence\n data[i] = {\n token = objData,\n value = value or precedence[1]\n }\n\n -- order for comparator function\n if precedence ~= nil then\n data[i].order = precedence[2]\n else\n data[i].order = value\n end\n end\n\n -- sort table by value (symbols last if same value)\n table.sort(data, tokenValueComparator)\n\n -- laying out the tokens\n local pos = self.getPosition() + Vector(3.55, -0.05, -3.95)\n if percentage then pos.z = pos.z - 3.05 end\n\n local location = { x = pos.x, y = pos.y, z = pos.z }\n local rotation = self.getRotation()\n local currentValue = data[1].value\n local tokenCount = { row = 0, sum = 0, total = #data }\n local valueCount = 1\n local tokenName = false\n\n for i, item in ipairs(data) do\n -- this is true for the first token in a new row\n if item.value ~= currentValue then\n if percentage then\n tokenCount.sum = tokenCount.sum + tokenCount.row\n createPercentageButton(tokenCount, valueCount, tokenName)\n end\n\n location.x = location.x - 1.75\n location.z = pos.z\n currentValue = item.value\n valueCount = valueCount + 1\n tokenCount.row = 0\n end\n\n spawnObjectData({\n data = item.token,\n position = location,\n rotation = rotation\n })\n tokenName = item.token.Nickname\n location.z = location.z - 1.75\n tokenCount.row = tokenCount.row + 1\n end\n\n -- this is repeated to create the button for the last token\n if percentage then\n tokenCount.sum = tokenCount.sum + tokenCount.row\n createPercentageButton(tokenCount, valueCount, tokenName)\n end\n\n -- introducing a small delay to limit update calls\n Wait.time(function() updating = false end, 0.1)\nend\n\n-- called from outside to set default values for tokens\nfunction onTokenDataChanged(parameters)\n local tokenData = parameters.tokenData or {}\n local currentScenario = parameters.currentScenario or \"\"\n local useFrontData = parameters.useFrontData\n\n -- update token precedence\n for key, table in pairs(tokenData) do\n local modifier = table.modifier\n if modifier == -999 then modifier = 0 end\n tokenPrecedence[key][1] = modifier\n end\n\n updateUI()\n layout()\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"core/MythosAreaApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local MythosAreaApi = {}\n local guidReferenceApi = require(\"core/GUIDReferenceApi\")\n\n local function getMythosArea()\n return guidReferenceApi.getObjectByOwnerAndType(\"Mythos\", \"MythosArea\")\n end\n\n ---@return any: Table of chaos token metadata (if provided through scenario reference card)\n MythosAreaApi.returnTokenData = function()\n return getMythosArea().call(\"returnTokenData\")\n end\n \n ---@return any: Object reference to the encounter deck\n MythosAreaApi.getEncounterDeck = function()\n return getMythosArea().call(\"getEncounterDeck\")\n end\n\n -- draw an encounter card for the requesting mat to the first empty spot from the right \n ---@param matColor string Playermat that triggered this\n ---@param position tts__Vector Position for the encounter card\n MythosAreaApi.drawEncounterCard = function(matColor, position)\n getMythosArea().call(\"drawEncounterCard\", { matColor = matColor, position = position })\n end\n\n -- reshuffle the encounter deck\n MythosAreaApi.reshuffleEncounterDeck = function()\n getMythosArea().call(\"reshuffleEncounterDeck\")\n end\n \n return MythosAreaApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "{\"includeDrawnTokens\":true,\"percentage\":false,\"tokenPrecedence\":{\"\":[0,11],\"Auto-fail\":[-100,7],\"Bless\":[101,8],\"Cultist\":[-2,4],\"Curse\":[-101,9],\"Elder Sign\":[100,2],\"Elder Thing\":[-4,6],\"Frost\":[-99,10],\"Skull\":[-1,3],\"Tablet\":[-3,5]}}", "MeasureMovement": false, "Name": "Custom_Token", @@ -205702,7 +208919,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"chaosbag/ChaosBagManager\")\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\n\nlocal TOKEN_IDS = {\n -- first row\n \"p1\", \"0\", \"m1\", \"m2\", \"m3\", \"m4\",\n -- second row\n \"m5\", \"m6\", \"m7\", \"m8\", \"frost\",\n -- third row\n \"blue\", \"skull\", \"cultist\", \"tablet\", \"elder\", \"red\"\n}\n\nlocal BUTTON_TOOLTIP = {\n -- first row\n \"+1\", \"0\", \"-1\", \"-2\", \"-3\", \"-4\",\n -- second row\n \"-5\", \"-6\", \"-7\", \"-8\", \"Frost\",\n -- third row\n \"Elder Sign\", \"Skull\", \"Cultist\", \"Tablet\", \"Elder Thing\", \"Auto-fail\"\n}\n\nlocal BUTTON_POSITION_X = {\n -- first row\n -0.9, -0.54, -0.18, 0.18, 0.54, 0.9,\n -- second row\n -0.9, -0.54, -0.18, 0.18, 0.9,\n -- third row\n -0.9, -0.54, -0.18, 0.18, 0.54, 0.9\n}\n\nlocal BUTTON_POSITION_Z = { -0.298, 0.05, 0.399 }\n\n-- common button parameters\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.color = { 0, 0, 0, 0 }\nbuttonParameters.width = 160\nbuttonParameters.height = 160\n\nfunction onLoad()\n -- create buttons for tokens\n for i = 1, #BUTTON_POSITION_X do\n local funcName = \"buttonClick\" .. i\n self.setVar(funcName, function(_, _, isRightClick) buttonClick(i, isRightClick) end)\n\n buttonParameters.click_function = funcName\n buttonParameters.tooltip = BUTTON_TOOLTIP[i]\n buttonParameters.position = { x = BUTTON_POSITION_X[i], y = 0 }\n\n if i \u003c 7 then\n buttonParameters.position.z = BUTTON_POSITION_Z[1]\n elseif i \u003c 12 then\n buttonParameters.position.z = BUTTON_POSITION_Z[2]\n else\n buttonParameters.position.z = BUTTON_POSITION_Z[3]\n end\n\n self.createButton(buttonParameters)\n end\nend\n\n-- click function for buttons\nfunction buttonClick(index, isRightClick)\n local tokenId = TOKEN_IDS[index]\n\n if isRightClick then\n chaosBagApi.removeChaosToken(tokenId)\n else\n local tokens = {}\n local name = BUTTON_TOOLTIP[index]\n local chaosbag = chaosBagApi.findChaosBag()\n\n for _, v in ipairs(chaosbag.getObjects()) do\n if v.name == name then table.insert(tokens, v.guid) end\n end\n\n -- spawn token (only 8 frost tokens allowed)\n if tokenId == \"frost\" and #tokens == 8 then\n printToAll(\"The maximum of 8 Frost tokens is already in the bag.\", \"Yellow\")\n return\n end\n\n chaosBagApi.spawnChaosToken(tokenId)\n printToAll(\"Adding \" .. name .. \" token (in bag: \" .. #tokens + 1 .. \")\", \"White\")\n end\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"chaosbag/ChaosBagManager\")\nend)\n__bundle_register(\"chaosbag/ChaosBagManager\", function(require, _LOADED, __bundle_register, __bundle_modules)\nlocal chaosBagApi = require(\"chaosbag/ChaosBagApi\")\n\nlocal TOKEN_IDS = {\n -- first row\n \"p1\", \"0\", \"m1\", \"m2\", \"m3\", \"m4\",\n -- second row\n \"m5\", \"m6\", \"m7\", \"m8\", \"frost\",\n -- third row\n \"blue\", \"skull\", \"cultist\", \"tablet\", \"elder\", \"red\"\n}\n\nlocal BUTTON_TOOLTIP = {\n -- first row\n \"+1\", \"0\", \"-1\", \"-2\", \"-3\", \"-4\",\n -- second row\n \"-5\", \"-6\", \"-7\", \"-8\", \"Frost\",\n -- third row\n \"Elder Sign\", \"Skull\", \"Cultist\", \"Tablet\", \"Elder Thing\", \"Auto-fail\"\n}\n\nlocal BUTTON_POSITION_X = {\n -- first row\n -0.9, -0.54, -0.18, 0.18, 0.54, 0.9,\n -- second row\n -0.9, -0.54, -0.18, 0.18, 0.9,\n -- third row\n -0.9, -0.54, -0.18, 0.18, 0.54, 0.9\n}\n\nlocal BUTTON_POSITION_Z = { -0.298, 0.05, 0.399 }\n\n-- common button parameters\nlocal buttonParameters = {}\nbuttonParameters.function_owner = self\nbuttonParameters.color = { 0, 0, 0, 0 }\nbuttonParameters.width = 160\nbuttonParameters.height = 160\n\nfunction onLoad()\n -- create buttons for tokens\n for i = 1, #BUTTON_POSITION_X do\n local funcName = \"buttonClick\" .. i\n self.setVar(funcName, function(_, _, isRightClick) buttonClick(i, isRightClick) end)\n\n buttonParameters.click_function = funcName\n buttonParameters.tooltip = BUTTON_TOOLTIP[i]\n buttonParameters.position = { x = BUTTON_POSITION_X[i], y = 0 }\n\n if i \u003c 7 then\n buttonParameters.position.z = BUTTON_POSITION_Z[1]\n elseif i \u003c 12 then\n buttonParameters.position.z = BUTTON_POSITION_Z[2]\n else\n buttonParameters.position.z = BUTTON_POSITION_Z[3]\n end\n\n self.createButton(buttonParameters)\n end\nend\n\n-- click function for buttons\nfunction buttonClick(index, isRightClick)\n local tokenId = TOKEN_IDS[index]\n\n if isRightClick then\n chaosBagApi.removeChaosToken(tokenId)\n else\n local tokens = {}\n local name = BUTTON_TOOLTIP[index]\n local chaosbag = chaosBagApi.findChaosBag()\n\n for _, v in ipairs(chaosbag.getObjects()) do\n if v.name == name then table.insert(tokens, v.guid) end\n end\n\n -- spawn token (only 8 frost tokens allowed)\n if tokenId == \"frost\" and #tokens == 8 then\n printToAll(\"The maximum of 8 Frost tokens is already in the bag.\", \"Yellow\")\n return\n end\n\n chaosBagApi.spawnChaosToken(tokenId)\n printToAll(\"Adding \" .. name .. \" token (in bag: \" .. #tokens + 1 .. \")\", \"White\")\n end\nend\nend)\n__bundle_register(\"chaosbag/ChaosBagApi\", function(require, _LOADED, __bundle_register, __bundle_modules)\ndo\n local ChaosBagApi = {}\n\n -- respawns the chaos bag with a new state of tokens\n ---@param tokenList table List of chaos token ids\n ChaosBagApi.setChaosBagState = function(tokenList)\n return Global.call(\"setChaosBagState\", tokenList)\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getChaosBagState = function()\n local chaosBagContentsCatcher = Global.call(\"getChaosBagState\")\n local chaosBagContents = {}\n for _, v in ipairs(chaosBagContentsCatcher) do\n table.insert(chaosBagContents, v)\n end\n return chaosBagContents\n end\n\n -- checks scripting zone for chaos bag (also called by a lot of objects!)\n ChaosBagApi.findChaosBag = function()\n return Global.call(\"findChaosBag\")\n end\n\n -- returns a table of object references to the tokens in play (does not include sealed tokens!)\n ChaosBagApi.getTokensInPlay = function()\n return Global.call(\"getChaosTokensinPlay\")\n end\n\n -- returns all sealed tokens on cards to the chaos bag\n ---@param playerColor string Color of the player to show the broadcast to\n ChaosBagApi.releaseAllSealedTokens = function(playerColor)\n return Global.call(\"releaseAllSealedTokens\", playerColor)\n end\n\n -- returns all drawn tokens to the chaos bag\n ChaosBagApi.returnChaosTokens = function()\n return Global.call(\"returnChaosTokens\")\n end\n\n -- removes the specified chaos token from the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.removeChaosToken = function(id)\n return Global.call(\"removeChaosToken\", id)\n end\n\n -- returns a chaos token to the bag and calls all relevant functions\n ---@param token tts__Object Chaos token to return\n ChaosBagApi.returnChaosTokenToBag = function(token)\n return Global.call(\"returnChaosTokenToBag\", token)\n end\n\n -- spawns the specified chaos token and puts it into the chaos bag\n ---@param id string ID of the chaos token\n ChaosBagApi.spawnChaosToken = function(id)\n return Global.call(\"spawnChaosToken\", id)\n end\n\n -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens\n -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the\n -- contents of the bag should check this method before doing so.\n -- This method will broadcast a message to all players if the bag is being searched.\n ---@return any canTouch True if the bag is manipulated, false if it should be blocked.\n ChaosBagApi.canTouchChaosTokens = function()\n return Global.call(\"canTouchChaosTokens\")\n end\n\n -- called by playermats (by the \"Draw chaos token\" button)\n ---@param mat tts__Object Playermat that triggered this\n ---@param drawAdditional boolean Controls whether additional tokens should be drawn\n ---@param tokenType? string Name of token (e.g. \"Bless\") to be drawn from the bag\n ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag\n ---@param returnedToken? tts__Object Token to be replaced with newly drawn token\n ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)\n return Global.call(\"drawChaosToken\", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})\n end\n\n -- returns a Table List of chaos token ids in the current chaos bag\n -- requires copying the data into a new table because TTS is weird about handling table return values in Global\n ChaosBagApi.getIdUrlMap = function()\n return Global.getTable(\"ID_URL_MAP\")\n end\n\n return ChaosBagApi\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Tile", @@ -205750,7 +208967,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "BlockRectangle", @@ -205806,7 +209023,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", + "LuaScript": "-- Bundled by luabundle {\"version\":\"1.6.0\"}\nlocal __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)\n\tlocal loadingPlaceholder = {[{}] = true}\n\n\tlocal register\n\tlocal modules = {}\n\n\tlocal require\n\tlocal loaded = {}\n\n\tregister = function(name, body)\n\t\tif not modules[name] then\n\t\t\tmodules[name] = body\n\t\tend\n\tend\n\n\trequire = function(name)\n\t\tlocal loadedModule = loaded[name]\n\n\t\tif loadedModule then\n\t\t\tif loadedModule == loadingPlaceholder then\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\tif not modules[name] then\n\t\t\t\tif not superRequire then\n\t\t\t\t\tlocal identifier = type(name) == 'string' and '\\\"' .. name .. '\\\"' or tostring(name)\n\t\t\t\t\terror('Tried to require ' .. identifier .. ', but no such module has been registered')\n\t\t\t\telse\n\t\t\t\t\treturn superRequire(name)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tloaded[name] = loadingPlaceholder\n\t\t\tloadedModule = modules[name](require, loaded, register, modules)\n\t\t\tloaded[name] = loadedModule\n\t\tend\n\n\t\treturn loadedModule\n\tend\n\n\treturn require, loaded, register, modules\nend)(nil)\n__bundle_register(\"__root\", function(require, _LOADED, __bundle_register, __bundle_modules)\nrequire(\"core/DownloadBox\")\nend)\n__bundle_register(\"core/DownloadBox\", function(require, _LOADED, __bundle_register, __bundle_modules)\nfunction onLoad()\n local notes = self.getGMNotes()\n\n -- default parameters (e.g. scenarios)\n local buttonParameters = {\n label = \"Download\",\n click_function = \"buttonClick_download\",\n function_owner = self,\n position = { x = 0, y = 0.1, z = 2.1 },\n height = 250,\n width = 800,\n font_size = 150,\n color = { 0, 0, 0 },\n font_color = { 1, 1, 1 }\n }\n\n -- return to boxes\n if string.match(notes, \"................\") == \"campaigns/return\" then\n buttonParameters.position.z = 2\n\n -- official campaign boxes\n elseif string.match(notes, \".........\") == \"campaigns\" or self.hasTag(\"LargeBox\") then\n buttonParameters.position.z = 6\n buttonParameters.height = 500\n buttonParameters.width = 1700\n buttonParameters.font_size = 350\n\n -- investigator boxes\n elseif string.match(notes, \".............\") == \"investigators\" then\n buttonParameters.position.z = 7\n buttonParameters.height = 850\n buttonParameters.width = 3400\n buttonParameters.font_size = 700\n end\n\n self.createButton(buttonParameters)\nend\n\nfunction buttonClick_download(_, playerColor)\n Global.call('placeholder_download', { url = self.getGMNotes(), player = playerColor and Player[playerColor] or nil, replace = self.guid })\nend\nend)\nreturn __bundle_require(\"__root\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", @@ -206972,10 +210189,10 @@ "g": 1, "r": 1 }, - "Description": "Thanks for downloading Arkham SCE 3.7.0!\n\n- Feast of Hemlock Vale Campaign Expansion is now fully released!\n- Updated all FoHV player cards with high-quality scans!\n- Also updated Edge of the Earth player cards!\n- Implemented cards from the latest Taboo list update.", + "Description": "Thanks for downloading Arkham SCE 3.8.0!\n\nAdded Parallel Rex Murphy to the deck importer!\r\nPlaymat slots are now editable via a new button!\nThe options panel has been updated with a new look.\r\nEdge of the Earth weaknesses now spawn with a single Damage or Horror token as a reminder of how they can be removed.\r", "DragSelectable": true, "GMNotes": "", - "GUID": "6657b6", + "GUID": "bd6b3e", "Grid": true, "GridProjection": false, "Hands": false, @@ -206987,7 +210204,7 @@ "LuaScriptState": "", "MeasureMovement": false, "Name": "Notecard", - "Nickname": "Arkham SCE 3.7.0 - 3/5/2024 - Page 1", + "Nickname": "Arkham SCE 3.8.0 - 5/12/2024 - Page 1", "Snap": true, "States": { "2": { @@ -207002,10 +210219,10 @@ "g": 1, "r": 1 }, - "Description": "- Added a new card to the Fan-made Accessories barrel that can be used to easily track bonus VP that can't immediately be spent.\n- The \"Take Clue\" hotkey can now be used to take a clue from a clue pool bag, and has variants for multi-handed play.\n- Opening a menu (such as the downloads menu) no longer causes it to appear on every other player's screen.\n", + "Description": "Draw Encounter button now draws to the draw area on left-click, and to the rightmost empty threat area slot on right-click.\nCard states can now be changed with number keys.\r\nCleanup Helper now resets activation tokens.\r\nThe deck importer now can import Hemlock Vale story assets.\r\nHotkey Reference card has been updated.", "DragSelectable": true, "GMNotes": "", - "GUID": "a22c7e", + "GUID": "4a2b72", "Grid": true, "GridProjection": false, "Hands": false, @@ -207017,17 +210234,17 @@ "LuaScriptState": "", "MeasureMovement": false, "Name": "Notecard", - "Nickname": "Arkham SCE 3.7.0 - 3/5/2024 - Page 2", + "Nickname": "Arkham SCE 3.8.0 - 5/12/2024 - Page 2", "Snap": true, "Sticky": true, "Tooltip": true, "Transform": { - "posX": 8.080297, - "posY": 1.556635, - "posZ": -35.1032448, - "rotX": 0.00008872076, - "rotY": 89.97568, - "rotZ": 0.0284017846, + "posX": -27, + "posY": 1.55149889, + "posZ": -56.165, + "rotX": 4.07705976e-8, + "rotY": 90.00001, + "rotZ": 4.08891943e-9, "scaleX": 3, "scaleY": 1, "scaleZ": 3 @@ -207047,10 +210264,10 @@ "g": 1, "r": 1 }, - "Description": "- Implemented many miscellaneous bugfixes and metadata tweaks.\n\n- Extra-special thanks to everyone who helped us release Feast of Hemlock Vale as quickly as we could!!", + "Description": "Nkosi Mabati helper updated with custom token compatability.\nNew right-click option has been added Nepthys.\nRite of Sanctification no longer has to be right-clicked for each token sealed.\nFixed Ancient Covenant and Blasphemous Covenant having low-quality images.\nMyriad other under-the-hood code optimizations and bugfixes.", "DragSelectable": true, "GMNotes": "", - "GUID": "c01be8", + "GUID": "b27cd3", "Grid": true, "GridProjection": false, "Hands": false, @@ -207062,17 +210279,17 @@ "LuaScriptState": "", "MeasureMovement": false, "Name": "Notecard", - "Nickname": "Arkham SCE 3.7.0 - 3/5/2024 - Page 3", + "Nickname": "Arkham SCE 3.8.0 - 5/12/2024 - Page 3", "Snap": true, "Sticky": true, "Tooltip": true, "Transform": { - "posX": 48.5480232, + "posX": -27, "posY": 1.55149889, - "posZ": 2.98858, - "rotX": -8.131164e-8, + "posZ": -56.165, + "rotX": 5.014709e-8, "rotY": 90.00001, - "rotZ": 5.652705e-8, + "rotZ": 3.128093e-8, "scaleX": 3, "scaleY": 1, "scaleZ": 3 @@ -207107,7 +210324,7 @@ 0, 0 ], - "SaveName": "Arkham SCE - 3.7.0", + "SaveName": "Arkham SCE - 3.8.0", "Sky": "Sky_Museum", "SkyURL": "https://i.imgur.com/GkQqaOF.jpg", "SnapPoints": [ @@ -207498,5 +210715,5 @@ "Type": 0 }, "VersionNumber": "v13.2.2", - "XmlUI": "\u003c!-- include Global/Global.xml --\u003e\n\u003cDefaults\u003e\n \u003c!-- general stuff --\u003e\n \u003cText color=\"white\"\n fontSize=\"18\"/\u003e\n\u003c/Defaults\u003e\n\n\u003c!-- include Global/BottomBar.xml --\u003e\n\u003cDefaults\u003e\n \u003cButton class=\"navbar\"\n tooltipPosition=\"Left\"\n tooltipBackgroundColor=\"rgba(0,0,0,1)\"\n color=\"clear\"/\u003e\n\u003c/Defaults\u003e\n\n\u003c!-- Buttons at the bottom right (height: n * 37 - 2) --\u003e\n\u003cVerticalLayout visibility=\"Admin\"\n color=\"#000000\"\n outlineSize=\"1 1\"\n outline=\"#303030\"\n rectAlignment=\"LowerRight\"\n width=\"35\"\n height=\"72\"\n offsetXY=\"-1 120\"\n spacing=\"2\"\u003e\n \u003cButton class=\"navbar\"\n icon=\"devourer\"\n tooltip=\"Downloadable Content\"\n onClick=\"onClick_toggleUi(downloadWindow)\"/\u003e\n \u003cButton class=\"navbar\"\n icon=\"option-gear\"\n tooltip=\"Options\"\n onClick=\"onClick_toggleUi(optionPanel)\"/\u003e\n\u003c/VerticalLayout\u003e\n\n\u003c!-- Navigation Overlay button (not visibly to Grey and Black) --\u003e\n\u003cPanel visibility=\"White|Brown|Red|Orange|Yellow|Green|Teal|Blue|Purple|Pink\"\n color=\"#000000\"\n outlineSize=\"1 1\"\n outline=\"#303030\"\n rectAlignment=\"LowerRight\"\n width=\"35\"\n height=\"35\"\n offsetXY=\"-1 85\"\u003e\n \u003cButton class=\"navbar\"\n icon=\"NavigationOverlayIcon\"\n tooltip=\"Navigation Overlay\"\n onClick=\"onClick_toggleUi(Navigation Overlay)\"/\u003e\n\u003c/Panel\u003e\n\u003c!-- include Global/BottomBar.xml --\u003e\n\u003c!-- include Global/DownloadWindow.xml --\u003e\n\u003cDefaults\u003e\n \u003cButton class=\"downloadTab\"\n hoverClass=\"bGrey\"\n pressClass=\"bWhite\"\n onClick=\"onClick_tab\"\n color=\"#888888\"\n fontSize=\"24\"\n font=\"font_teutonic-arkham\"/\u003e\n \u003cButton class=\"bGrey\"\n color=\"grey\"/\u003e\n \u003cButton class=\"bWhite\"\n color=\"white\"/\u003e\n \u003cButton class=\"activeTab\"\n color=\"#ffffff\"/\u003e\n \u003cButton class=\"windowButton\"\n hoverClass=\"bGrey\"\n pressClass=\"bWhite\"\n selectClass=\"bWhite\"\n color=\"#888888\"\n font=\"font_teutonic-arkham\"/\u003e\n\u003c/Defaults\u003e\n\n\u003c!-- window to select downloadable content --\u003e\n\u003cVerticalLayout id=\"downloadWindow\"\n color=\"black\"\n active=\"false\"\n height=\"800\"\n width=\"900\"\n outlineSize=\"2 2\"\n outline=\"#303030\"\u003e\n\n \u003c!-- window header --\u003e\n \u003cPanel preferredHeight=\"60\"\n padding=\"10 10 5 5\"\n spacing=\"10\"\n outlineSize=\"2 2\"\n outline=\"#303030\"\n color=\"black\"\u003e\n \u003cText fontSize=\"32\"\n font=\"font_teutonic-arkham\"\n preferredWidth=\"600\"\n alignment=\"MiddleLeft\"\u003eDownloadable Content\u003c/Text\u003e\n \u003cButton id=\"downloadAll_button\"\n class=\"windowButton\"\n visibility=\"Black\"\n onClick=\"onClick_downloadAll\"\n height=\"30\"\n preferredWidth=\"110\"\n fontSize=\"20\"\n tooltip=\"Very rough estimate: 400 MB\"\n tooltipPosition=\"Above\"\n tooltipBackgroundColor=\"rgba(0,0,0,1)\"\u003eDownload Everything\u003c/Button\u003e\n \u003cButton id=\"spawnPlaceholder_button\"\n class=\"windowButton\"\n visibility=\"Black\"\n onClick=\"onClick_spawnPlaceholder\"\n height=\"30\"\n preferredWidth=\"110\"\n fontSize=\"20\"\u003eSpawn Placeholder\u003c/Button\u003e\n \u003cPanel preferredWidth=\"50\"\u003e\n \u003cButton rectAlignment=\"MiddleRight\"\n width=\"50\"\n color=\"clear\"\n icon=\"close\"\n tooltip=\"Close\"\n tooltipPosition=\"Right\"\n tooltipBackgroundColor=\"rgba(0,0,0,1)\"\n onClick=\"onClick_toggleUi(downloadWindow)\"/\u003e\n \u003c/Panel\u003e\n \u003c/Panel\u003e\n\n \u003cHorizontalLayout\u003e\n \u003cVerticalLayout preferredWidth=\"600\"\u003e\n \u003c!-- tab selection --\u003e\n \u003cHorizontalLayout preferredHeight=\"60\"\n padding=\"5\"\n spacing=\"5\"\u003e\n \u003cButton class=\"downloadTab activeTab\"\n id=\"tab1\"\u003eOfficial Campaigns\u003c/Button\u003e\n \u003cButton class=\"downloadTab\"\n id=\"tab2\"\u003eOfficial Scenarios\u003c/Button\u003e\n \u003cButton class=\"downloadTab\"\n id=\"tab3\"\u003eFan-Made Campaigns\u003c/Button\u003e\n \u003cButton class=\"downloadTab\"\n id=\"tab4\"\u003eFan-Made Scenarios\u003c/Button\u003e\n \u003cButton class=\"downloadTab\"\n id=\"tab5\"\u003eFan-Made Player Cards\u003c/Button\u003e\n \u003c/HorizontalLayout\u003e\n\n \u003c!-- content list --\u003e\n \u003cVerticalScrollView color=\"transparent\"\n minHeight=\"100\"\n flexibleHeight=\"100\"\n scrollSensitivity=\"27\"\n scrollbarColors=\"grey|grey|#C8C8C8|rgba(0.78,0.78,0.78,0.5)\"\n horizontalScrollbarVisibility=\"AutohideAndExpandViewport\"\n raycastTarget=\"true\"\u003e\n \u003cVerticalLayout id=\"contentList\"\n padding=\"10 25 0 0\"\u003e\n \u003c!-- this will be filled via scripting --\u003e\n \u003c/VerticalLayout\u003e\n \u003c/VerticalScrollView\u003e\n \u003c/VerticalLayout\u003e\n\n \u003c!-- content preview window --\u003e\n \u003cVerticalLayout preferredWidth=\"300\"\n padding=\"15 15 15 5\"\u003e\n\n \u003c!-- header --\u003e\n \u003cVerticalLayout preferredHeight=\"110\"\u003e\n \u003cText id=\"previewTitle\"\n fontSize=\"28\"\n preferredHeight=\"70\"\n font=\"font_teutonic-arkham\"\u003ePreviewTitle\u003c/Text\u003e\n \u003cText id=\"previewAuthor\"\n fontSize=\"20\"\n preferredHeight=\"40\"\n font=\"font_teutonic-arkham\"\u003eby PreviewAuthor\u003c/Text\u003e\n \u003c/VerticalLayout\u003e\n\n \u003c!-- box art --\u003e\n \u003cPanel id=\"previewArtPanel\"\n preferredHeight=\"390\"\u003e\n \u003cMask id=\"previewArtMask\"\u003e\n \u003c!-- image will be set via scripting --\u003e\n \u003cImage id=\"previewArtImage\" /\u003e\n \u003c/Mask\u003e\n \u003c/Panel\u003e\n\n \u003c!-- description --\u003e\n \u003cPanel preferredHeight=\"160\"\u003e\n \u003cText id=\"previewDescription\"\n alignment=\"UpperLeft\"\n resizeTextForBestFit=\"true\"\n resizeTextMinSize=\"12\"\n resizeTextMaxSize=\"18\"\u003ePreviewDescription\u003c/Text\u003e\n \u003c/Panel\u003e\n\n \u003c!-- download button / progress bar (visibility handled by lua code)--\u003e\n \u003cPanel preferredHeight=\"60\"\u003e\n \u003c!-- download button --\u003e\n \u003cButton id=\"download_button\"\n class=\"windowButton\"\n onClick=\"onClick_download\"\n height=\"50\"\n width=\"270\"\n fontSize=\"28\"\u003eDownload\u003c/Button\u003e\n \u003c!-- download progress bar --\u003e\n \u003cProgressBar id=\"download_progress\"\n active=\"false\"\n height=\"50\"\n width=\"270\"\n percentage=\"0\"\n color=\"#111111\"\n textColor=\"#aaaaaa\"\n fillImageColor=\"#333333\"/\u003e\n \u003c/Panel\u003e\n \u003c/VerticalLayout\u003e\n \u003c/HorizontalLayout\u003e\n\u003c/VerticalLayout\u003e\n\u003c!-- include Global/DownloadWindow.xml --\u003e\n\u003c!-- include Global/PlayAreaGallery.xml --\u003e\n\u003cDefaults\u003e\n \u003c!-- type selection at the top --\u003e\n \u003cButton class=\"imageTab\"\n hoverClass=\"bGrey\"\n pressClass=\"bWhite\"\n onClick=\"b7b45b/onClick_imageTab\"\n color=\"#888888\"\n fontSize=\"24\"\n font=\"font_teutonic-arkham\"/\u003e\n \u003cButton class=\"bGrey\"\n color=\"grey\"/\u003e\n \u003cButton class=\"bWhite\"\n color=\"white\"/\u003e\n\n \u003cButton class=\"windowButton\"\n hoverClass=\"bGrey\"\n pressClass=\"bWhite\"\n selectClass=\"bWhite\"\n color=\"#888888\"\n font=\"font_teutonic-arkham\"/\u003e\n\n \u003c!-- image boxes in the grid --\u003e\n \u003cVerticalLayout class=\"imageBox\"\n color=\"black\"\n outline=\"#303030\"\n outlineSize=\"2 2\"\n onClick=\"b7b45b/onClick_image\"/\u003e\n \u003cImage class=\"playareaImage\"\n preferredHeight=\"330\"/\u003e\n \u003cText class=\"imageName\"\n preferredHeight=\"40\"\n resizeTextForBestFit=\"true\"\n resizeTextMinSize=\"10\"\n resizeTextMaxSize=\"18\"/\u003e\n\n \u003c!-- item selection on the left --\u003e\n \u003cText class=\"itemText\"\n alignment=\"MiddleLeft\"/\u003e\n \u003cPanel class=\"itemPanel\"\n preferredHeight=\"45\"\n onClick=\"b7b45b/onClick_listItem\"/\u003e\n\n \u003c!-- other --\u003e\n \u003cText class=\"headerText\"\n fontSize=\"35\"/\u003e\n \u003cVerticalLayout childForceExpandHeight=\"false\"/\u003e\n\u003c/Defaults\u003e\n\n\u003cVerticalLayout id=\"playAreaGallery\"\n active=\"false\"\n color=\"black\"\n height=\"880\"\n width=\"900\"\n outlineSize=\"2 2\"\n outline=\"#303030\"\u003e\n\n \u003c!-- window header --\u003e\n \u003cPanel preferredHeight=\"60\"\n padding=\"10 10 5 5\"\n spacing=\"10\"\n outlineSize=\"2 2\"\n outline=\"#303030\"\n color=\"black\"\u003e\n \u003cText fontSize=\"32\"\n font=\"font_teutonic-arkham\"\n preferredWidth=\"600\"\n alignment=\"MiddleLeft\"\u003ePlayarea Image Gallery\u003c/Text\u003e\n \u003cButton id=\"customUrl_button\"\n class=\"windowButton\"\n onClick=\"onClick_customUrl\"\n height=\"30\"\n preferredWidth=\"125\"\n fontSize=\"24\"\u003eUse custom URL\u003c/Button\u003e\n \u003cPanel preferredWidth=\"50\"\u003e\n \u003cButton rectAlignment=\"MiddleRight\"\n width=\"50\"\n color=\"clear\"\n icon=\"close\"\n tooltip=\"Close\"\n tooltipPosition=\"Right\"\n tooltipBackgroundColor=\"rgba(0,0,0,1)\"\n onClick=\"onClick_toggleUi(playAreaGallery)\"/\u003e\n \u003c/Panel\u003e\n \u003c/Panel\u003e\n\n \u003c!-- tab selection --\u003e\n \u003cHorizontalLayout preferredHeight=\"60\"\n padding=\"5\"\n spacing=\"5\"\u003e\n \u003cButton class=\"imageTab\"\n id=\"imageTab1\"\u003eOfficial Campaigns\u003c/Button\u003e\n \u003cButton class=\"imageTab\"\n id=\"imageTab2\"\u003eOfficial Scenarios\u003c/Button\u003e\n \u003cButton class=\"imageTab\"\n id=\"imageTab3\"\u003eFan-Made Campaigns\u003c/Button\u003e\n \u003cButton class=\"imageTab\"\n id=\"imageTab4\"\u003eFan-Made Scenarios\u003c/Button\u003e\n \u003cButton class=\"imageTab\"\n id=\"imageTab5\"\u003eOther Images\u003c/Button\u003e\n \u003c/HorizontalLayout\u003e\n\n \u003cHorizontalLayout preferredHeight=\"760\"\u003e\n \u003c!-- left column: navigation bar --\u003e\n \u003cVerticalLayout id=\"itemSelection\"\n preferredWidth=\"180\"\n padding=\"10 15 0 0\"\u003e\n \u003c!-- this will be filled via scripting --\u003e\n \u003c!-- \u003cPanel class=\"itemPanel\"\u003e\n \u003cText class=\"itemText\"\u003eItem\u003c/Text\u003e\n \u003c/Panel\u003e --\u003e\n \u003c/VerticalLayout\u003e\n\n \u003c!-- right column: image gallery --\u003e\n \u003cVerticalScrollView color=\"transparent\"\n minHeight=\"100\"\n flexibleHeight=\"100\"\n preferredWidth=\"720\"\n scrollSensitivity=\"380\"\n scrollbarColors=\"grey|grey|#C8C8C8|rgba(0.78,0.78,0.78,0.5)\"\n horizontalScrollbarVisibility=\"AutohideAndExpandViewport\"\n raycastTarget=\"true\"\u003e\n \u003cGridLayout id=\"playareaList\"\n preferredWidth=\"700\"\n padding=\"25 25 5 5\"\n spacing=\"10\"\n cellSize=\"330 370\"\u003e\n \u003c!-- this will be filled via scripting --\u003e\n \u003c!-- \u003cVerticalLayout class=\"imageBox\"\u003e\n \u003cImage class=\"playareaImage\" image=\"\"/\u003e\n \u003cText class=\"imageName\"\u003eImage Name\u003c/Text\u003e\n \u003c/VerticalLayout\u003e --\u003e\n \u003c/GridLayout\u003e\n \u003c/VerticalScrollView\u003e\n \u003c/HorizontalLayout\u003e\n\u003c/VerticalLayout\u003e\n\u003c!-- include Global/PlayAreaGallery.xml --\u003e\n\u003c!-- include Global/TitleSplash.xml --\u003e\n\u003c!-- Title Splash when starting a scenario --\u003e\n\u003cPanel id=\"title_splash\"\n height=\"220\"\n position=\"0 250 0\"\n showAnimation=\"FadeIn\"\n hideAnimation=\"FadeOut\"\n active=\"false\"\n animationDuration=\"2\"\u003e\n \u003cImage id=\"title_gradient\"\n height=\"220\"\n image=\"TitleGradient\" /\u003e\n \u003cText id=\"title_splash_text\"\n width=\"95%\"\n height=\"180\"\n resizeTextForBestFit=\"true\"\n resizeTextMinSize=\"100\"\n resizeTextMaxSize=\"150\"\n font=\"font_teutonic-arkham\"\n outline=\"black\"\n outlineSize=\"3 -3\"\n horizontalOverflow=\"Overflow\"\u003e\n \u003c/Text\u003e\n\u003c/Panel\u003e\n\u003c!-- include Global/TitleSplash.xml --\u003e\n\u003c!-- include Global/NavigationOverlay.xml --\u003e\n\u003c!-- Default formatting --\u003e\n\u003cDefaults\u003e\n \u003cText color=\"#FFFFFF\"\n alignment=\"MiddleLeft\" /\u003e\n\n \u003cToggle isOn=\"False\"\n rectAlignment=\"MiddleRight\" /\u003e\n\n \u003cCell dontUseTableCellBackground=\"true\"\n outlineSize=\"0 1\"\n outline=\"grey\" /\u003e\n\n \u003c!-- options --\u003e\n \u003cRow class=\"nav_option-text\"\n preferredHeight=\"45\"/\u003e\n \u003cCell class=\"nav_option-text\"\n color=\"#333333\"/\u003e\n \u003cCell class=\"nav_option-button\"\n color=\"#333333\"/\u003e\n \u003cText class=\"nav_option-header\"\n fontSize=\"20\"\n font=\"font_teutonic-arkham\"/\u003e\n \u003cCell class=\"claim\"\n tooltip=\"Clicking this seat in the navigation overlay\u0026#xA;will now only swap the playercolor for you.\"\n tooltipPosition=\"Right\" /\u003e\n\n \u003c!-- buttons at the bottom --\u003e\n \u003cButton class=\"bottomButtons\"\n hoverClass=\"hover\"\n pressClass=\"press\"\n selectClass=\"select\"\n color=\"#888888\"\n minHeight=\"35\"\n fontSize=\"24\"\n font=\"font_teutonic-arkham\"/\u003e\n \u003cButton class=\"hover\"\n color=\"grey\"/\u003e\n \u003cButton class=\"press\"\n color=\"white\"/\u003e\n \u003cButton class=\"select\"\n color=\"white\"/\u003e\n\n \u003c!-- Navigation Panels --\u003e\n \u003cPanel class=\"navPanel\"\n active=\"false\"\n allowDragging=\"true\"\n rectAlignment=\"LowerRight\"\n returnToOriginalPositionWhenReleased=\"false\"\n offsetXY=\"-40 0\"\u003e\n \u003c/Panel\u003e\n\u003c/Defaults\u003e\n\n\u003c!-- full Panel --\u003e\n\u003cPanel id=\"navPanelFull\"\n height=\"358\"\n width=\"455\"\n class=\"navPanel\"\u003e\n\u003c/Panel\u003e\n\n\u003c!-- Play Area only --\u003e\n\u003cPanel id=\"navPanelPlay\"\n height=\"208\"\n width=\"205\"\n class=\"navPanel\"\u003e\n\u003c/Panel\u003e\n\n\u003c!-- Settings --\u003e\n\u003cTableLayout id=\"navPanelSettings\"\n active=\"false\"\n width=\"300\"\n height=\"380\"\n color=\"#000000\"\n outlineSize=\"2 2\"\n outline=\"grey\"\n rectAlignment=\"MiddleCenter\"\u003e\n\n \u003c!-- Header --\u003e\n \u003cRow preferredHeight=\"60\"\u003e\n \u003cCell\u003e\n \u003cPanel padding=\"10 0 0 0\"\u003e\n \u003cText font=\"font_teutonic-arkham\"\n fontSize=\"35\"\u003eNavigation Overlay\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Options --\u003e\n \u003cRow\u003e\n \u003cCell\u003e\n \u003cTableLayout columnWidths=\"0 125\"\n autoCalculateHeight=\"1\"\n cellPadding=\"10 0 5 5\"\u003e\n\n \u003c!-- Option: Custom pitch --\u003e\n \u003cRow class=\"nav_option-text\"\u003e\n \u003cCell class=\"nav_option-text\"\u003e\n \u003cText class=\"nav_option-header\"\u003eViewing angle in degrees:\u003c/Text\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"nav_option-button\"\u003e\n \u003cSlider id=\"sliderPitch\"\n onValueChanged=\"797ede/updatePitch\"\n wholeNumbers=\"true\"\n minValue=\"0\"\n maxValue=\"89\"\n value=\"75\"\n tooltip=\"This controls the camera pitch\u0026#xA;('nodding your head').\"\n tooltipPosition=\"Right\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: Custom distance --\u003e\n \u003cRow class=\"nav_option-text\"\u003e\n \u003cCell class=\"nav_option-text\"\u003e\n \u003cText class=\"nav_option-header\"\u003eViewing distance (relative):\u003c/Text\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"nav_option-button\"\u003e\n \u003cSlider id=\"sliderDistance\"\n onValueChanged=\"797ede/updateDistance\"\n wholeNumbers=\"true\"\n minValue=\"50\"\n maxValue=\"200\"\n value=\"100\"\n tooltip=\"This controls the camera distance\u0026#xA;(from 50% to 200% of the default settings).\"\n tooltipPosition=\"Right\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: Claim White --\u003e\n \u003cRow class=\"nav_option-text\"\u003e\n \u003cCell class=\"nav_option-text\"\u003e\n \u003cText class=\"nav_option-header\"\u003eClaim \"White\" seat\u003c/Text\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"nav_option-button claim\"\u003e\n \u003cToggle id=\"claimWhite\"\n onValueChanged=\"797ede/claimColor(White)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: Claim Orange --\u003e\n \u003cRow class=\"nav_option-text\"\u003e\n \u003cCell class=\"nav_option-text\"\u003e\n \u003cText class=\"nav_option-header\"\u003eClaim \"Orange\" seat\u003c/Text\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"nav_option-button claim\"\u003e\n \u003cToggle id=\"claimOrange\"\n onValueChanged=\"797ede/claimColor(Orange)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: Claim Green --\u003e\n \u003cRow class=\"nav_option-text\"\u003e\n \u003cCell class=\"nav_option-text\"\u003e\n \u003cText class=\"nav_option-header\"\u003eClaim \"Green\" seat\u003c/Text\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"nav_option-button claim\"\u003e\n \u003cToggle id=\"claimGreen\"\n onValueChanged=\"797ede/claimColor(Green)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: Claim Red --\u003e\n \u003cRow class=\"nav_option-text\"\u003e\n \u003cCell class=\"nav_option-text\"\u003e\n \u003cText class=\"nav_option-header\"\u003eClaim \"Red\" seat\u003c/Text\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"nav_option-button claim\"\u003e\n \u003cToggle id=\"claimRed\"\n onValueChanged=\"797ede/claimColor(Red)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n \u003c/TableLayout\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Buttons: Defaults and Close --\u003e\n \u003cRow preferredHeight=\"50\"\u003e\n \u003cCell\u003e\n \u003cHorizontalLayout minHeight=\"55\"\n flexibleHeight=\"0\"\n padding=\"10 10 5 10\"\n spacing=\"35\"\u003e\n \u003cButton class=\"bottomButtons\"\n onClick=\"797ede/loadDefaultSettings\"\u003eLoad defaults\u003c/Button\u003e\n \u003cButton class=\"bottomButtons\"\n onClick=\"797ede/toggleSettings\"\u003eClose\u003c/Button\u003e\n \u003c/HorizontalLayout\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\u003c/TableLayout\u003e\n\u003c!-- include Global/NavigationOverlay.xml --\u003e\n\u003c!-- include Global/OptionPanel.xml --\u003e\n\u003c!-- Default formatting --\u003e\n\u003cDefaults\u003e\n \u003cText color=\"#FFFFFF\"\n alignment=\"MiddleLeft\" /\u003e\n\n \u003cToggle isOn=\"False\"\n rectAlignment=\"MiddleRight\" /\u003e\n\n \u003cDropdown rectAlignment=\"MiddleCenter\" /\u003e\n\n \u003cCell dontUseTableCellBackground=\"true\"\n outlineSize=\"0 1\"\n outline=\"grey\" /\u003e\n\n \u003c!-- main window --\u003e\n \u003cTableLayout class=\"window\"\n width=\"500\"\n height=\"800\"\n active=\"false\"\n color=\"#000000\"\n outlineSize=\"2 2\"\n outline=\"grey\"\n showAnimation=\"SlideIn_Right\"\n hideAnimation=\"SlideOut_Right\"\n animationDuration=\"0.2\" /\u003e\n\n \u003c!-- group headers --\u003e\n \u003cRow class=\"group-header\"\n preferredHeight=\"44\" /\u003e\n \u003cCell class=\"group-header\"\n padding=\"10 10 0 0\"\n columnSpan=\"3\"\n color=\"#222222\" /\u003e\n \u003cPanel class=\"group-header\"\n padding=\"5 0 0 0\" /\u003e\n \u003cText class=\"group-header\"\n fontSize=\"28\"\n font=\"font_teutonic-arkham\" /\u003e\n\n \u003c!-- options --\u003e\n \u003cRow class=\"option-text\"\n preferredHeight=\"50\"\n tooltipPosition=\"Left\"\n tooltipBackgroundColor=\"rgba(0,0,0,1)\"/\u003e\n \u003cCell class=\"option-text\"\n padding=\"10 10 5 5\"\n color=\"#333333\"\n columnSpan=\"2\"/\u003e\n \u003cCell class=\"option-button\"\n padding=\"10 10 5 5\"\n color=\"#333333\"/\u003e\n \u003cCell class=\"option-singleColumn\"\n padding=\"10 10 5 5\"\n color=\"#333333\"\n columnSpan=\"1\"/\u003e\n \u003cCell class=\"option-doubleColumn\"\n padding=\"10 10 5 5\"\n color=\"#333333\"\n columnSpan=\"2\"/\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\n padding=\"10 0 0 0\"/\u003e\n \u003cText class=\"option-header\"\n fontSize=\"22\"\n font=\"font_teutonic-arkham\"/\u003e\n \u003cPanel class=\"doubleColumn-wrapper\"\n padding=\"0 17 3 3\"/\u003e\n\n \u003c!-- buttons at the bottom --\u003e\n \u003cButton class=\"bottomButtons\"\n hoverClass=\"hover\"\n pressClass=\"press\"\n selectClass=\"select\"\n color=\"#888888\"\n minHeight=\"35\"\n fontSize=\"24\"\n font=\"font_teutonic-arkham\"/\u003e\n \u003cButton class=\"hover\"\n color=\"grey\"/\u003e\n \u003cButton class=\"press\"\n color=\"white\"/\u003e\n \u003cButton class=\"select\"\n color=\"white\"/\u003e\n\u003c/Defaults\u003e\n\n\u003c!-- Option Panel --\u003e\n\u003cTableLayout id=\"optionPanel\"\n class=\"window\"\n rectAlignment=\"LowerRight\"\n offsetXY=\"-50 80\"\n raycastTarget=\"true\"\u003e\n \u003c!-- Header: Options --\u003e\n \u003cRow preferredHeight=\"60\"\u003e\n \u003cCell\u003e\n \u003cPanel padding=\"10 0 0 0\"\u003e\n \u003cText font=\"font_teutonic-arkham\"\n fontSize=\"35\"\u003eOptions\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Scrollable part with options --\u003e\n \u003cRow\u003e\n \u003cCell\u003e\n \u003cVerticalScrollView horizontalScrollbarVisibility=\"AutohideAndExpandViewport\"\n scrollSensitivity=\"30\"\n raycastTarget=\"true\"\u003e\n \u003cTableLayout columnWidths=\"0 100 75\"\n autoCalculateHeight=\"1\"\n useGlobalCellPadding=\"false\"\u003e\n\n \u003c!-- Group: general settings --\u003e\n \u003cRow class=\"group-header\"\u003e\n \u003cCell class=\"group-header\"\u003e\n \u003cPanel class=\"group-header\"\n image=\"header_acolyte\"\u003e\n \u003cText class=\"group-header\"\u003eGENERAL SETTINGS\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: card language --\u003e\n \u003c!-- disabled until we have the backend in place\n \u003cRow class=\"option-text\" tooltip=\"Downloading a campaign or importing a deck will use\u0026#xA;this language for cards (NOT FUNCTIONAL YET!).\"\u003e\n \u003cCell class=\"option-singleColumn\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eCard language\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-doubleColumn\"\u003e\n \u003cPanel class=\"doubleColumn-wrapper\"\u003e\n \u003cDropdown id=\"cardLanguage\" onValueChanged=\"languageSelected(selectedIndex)\"\u003e\n \u003cOption\u003e简体中文\u003c/Option\u003e\n \u003cOption\u003e繁體中文\u003c/Option\u003e\n \u003cOption\u003eDeutsch\u003c/Option\u003e\n \u003cOption\u003eEnglish\u003c/Option\u003e\n \u003cOption\u003eEspañol\u003c/Option\u003e\n \u003cOption\u003eFrançais\u003c/Option\u003e\n \u003cOption\u003eItaliano\u003c/Option\u003e\n \u003c/Dropdown\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e --\u003e\n\n \u003c!-- Option: splash scenario name on setup --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Fade in the name of the scenario for 2 seconds\u0026#xA;when placing down a scenario.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eShow scenario title on setup\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cToggle id=\"showTitleSplash\"\n onValueChanged=\"onClick_toggleOption(showTitleSplash)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Group: play area settings --\u003e\n \u003cRow class=\"group-header\"\u003e\n \u003cCell class=\"group-header\"\u003e\n \u003cPanel class=\"group-header\"\n image=\"header_compass\"\u003e\n \u003cText class=\"group-header\"\u003ePLAY AREA SETTINGS\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: play area snap tags --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Only cards with the tag 'Location' will snap (official cards are supported by default).\u0026#xA;Disable this if you are having issues with custom content.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eEnable snap tags\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cToggle id=\"playAreaSnapTags\"\n onValueChanged=\"onClick_toggleOption(playAreaSnapTags)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: location connections --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Automatically draw location connections based on card metadata.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eDraw location connections\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cToggle id=\"playAreaConnections\"\n onValueChanged=\"onClick_toggleOption(playAreaConnections)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: play area connection color --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"This color will be used to draw lines\u0026#xA;for location connections.\"\u003e\n \u003cCell class=\"option-singleColumn\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eChoose color for location connections\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-doubleColumn\"\u003e\n \u003cPanel class=\"doubleColumn-wrapper\"\u003e\n \u003cButton id=\"playAreaConnectionColor\"\n onClick=\"onClick_playAreaConnectionColor\"\u003e\n \u003c/Button\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: change custom playarea image on setup --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Attempts to set the play area to a fitting image\u0026#xA;from the play area image gallery.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eChange background on setup\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cToggle id=\"changePlayAreaImage\"\n onValueChanged=\"onClick_toggleOption(changePlayAreaImage)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Group: playermat settings --\u003e\n \u003cRow class=\"group-header\"\u003e\n \u003cCell class=\"group-header\"\u003e\n \u003cPanel class=\"group-header\"\n image=\"header_cover\"\u003e\n \u003cText class=\"group-header\"\u003ePLAYERMAT SETTINGS\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: enable snap tags --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Only cards with the tag 'Asset' will snap (official cards are supported by default).\u0026#xA;Disable this if you are having issues with custom content.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eEnable snap tags\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cToggle id=\"useSnapTags\"\n onValueChanged=\"onClick_toggleOption(useSnapTags)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: show draw 1 button --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Displays a button below the 'Upkeep' button that draws a card from your deck.\u0026#xA;Useful for multi-handed solo play.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eShow \"Draw 1\" button\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cToggle id=\"showDrawButton\"\n onValueChanged=\"onClick_toggleOption(showDrawButton)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: use clickable clue-counters --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Instead of automatically counting clues in the respective area on your playermat,\u0026#xA;this displays a clickable counter for clues.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eUse clickable clue counters\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cToggle id=\"useClueClickers\"\n onValueChanged=\"onClick_toggleOption(useClueClickers)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: use clickable resource counters --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"This enables spawning of clickable resource tokens for player cards.\u0026#xA;(Chef's Selection = assets with 0 uses)\"\u003e\n \u003cCell class=\"option-singleColumn\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eUse clickable resource tokens\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-doubleColumn\"\u003e\n \u003cPanel class=\"doubleColumn-wrapper\"\u003e\n \u003cDropdown id=\"useResourceCounters\"\n onValueChanged=\"resourceCounterSelected(selectedIndex)\"\u003e\n \u003cOption\u003eEnabled\u003c/Option\u003e\n \u003cOption\u003eChef's Selection\u003c/Option\u003e\n \u003cOption\u003eDisabled\u003c/Option\u003e\n \u003c/Dropdown\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: remove a player mat --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Remove an unused playermat for more table space.\u0026#xA;Displayed are the default colors.\"\u003e\n \u003cCell class=\"option-singleColumn\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eRemove a playermat\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-doubleColumn\"\u003e\n \u003cPanel class=\"doubleColumn-wrapper\"\u003e\n \u003cDropdown id=\"removePlayermat\"\n onValueChanged=\"playermatRemovalSelected(selectedIndex)\"\u003e\n \u003cOption\u003eClick to select\u003c/Option\u003e\n \u003cOption\u003e1: White\u003c/Option\u003e\n \u003cOption\u003e2: Orange\u003c/Option\u003e\n \u003cOption\u003e3: Green\u003c/Option\u003e\n \u003cOption\u003e4: Red\u003c/Option\u003e\n \u003c/Dropdown\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Group: fan-made accessories --\u003e\n \u003cRow class=\"group-header\"\u003e\n \u003cCell class=\"group-header\"\u003e\n \u003cPanel class=\"group-header\"\n image=\"header_olive\"\u003e\n \u003cText class=\"group-header\"\u003eFAN-MADE ACCESSORIES\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: show attachment helper --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Provides a card-sized bag for cards that are attached to other cards\u0026#xA;(e.g. Backpack).\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eAttachment Helper\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cToggle id=\"showAttachmentHelper\"\n onValueChanged=\"onClick_toggleOption(showAttachmentHelper)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: show clean up helper --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Useful for campaign-play:\u0026#xA;It resets play areas to allow continuous gameplay in the same savegame.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eClean Up Helper\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cToggle id=\"showCleanUpHelper\"\n onValueChanged=\"onClick_toggleOption(showCleanUpHelper)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: show CYOA campaign guides --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Displays in a 'Choose Your Own Adventure'\u0026#xA;style redesigned campaign guides.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eCYOA Campaign Guides\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cToggle id=\"showCYOA\"\n onValueChanged=\"onClick_toggleOption(showCYOA)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: show displacement tool --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"This allows moving all objects on the main play area\u0026#xA;in a chosen direction.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eDisplacement Tool\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cToggle id=\"showDisplacementTool\"\n onValueChanged=\"onClick_toggleOption(showDisplacementTool)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: show hand helper --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Never count your hand cards again! This tool does that for you\u0026#xA;and additionally enables easy discarding of random cards.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eHand Helper\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cToggle id=\"showHandHelper\"\n onValueChanged=\"onClick_toggleOption(showHandHelper)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: show search assistant --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Quickly search 3, 6, 9 or the top X\u0026#xA;cards of your deck!\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eSearch Assistant\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cToggle id=\"showSearchAssistant\"\n onValueChanged=\"onClick_toggleOption(showSearchAssistant)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n \u003c/TableLayout\u003e\n \u003c/VerticalScrollView\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Buttons: Defaults and Close --\u003e\n \u003cRow preferredHeight=\"50\"\u003e\n \u003cCell\u003e\n \u003cHorizontalLayout minHeight=\"55\"\n flexibleHeight=\"0\"\n padding=\"10 10 5 10\"\n spacing=\"225\"\u003e\n \u003cButton class=\"bottomButtons\"\n onClick=\"onClick_defaultSettings\"\u003eLoad defaults\u003c/Button\u003e\n \u003cButton class=\"bottomButtons\"\n onClick=\"onClick_toggleUi(optionPanel)\"\u003eClose\u003c/Button\u003e\n \u003c/HorizontalLayout\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\u003c/TableLayout\u003e\n\u003c!-- include Global/OptionPanel.xml --\u003e\n\u003c!-- include Global/UpdateNotification.xml --\u003e\n\u003c!-- Default formatting inherented from OptionPanel! --\u003e\n\n\u003c!-- Icon with Finn, which can be clicked --\u003e\n\u003cImage id=\"FinnIcon\"\n active=\"false\"\n showAnimation=\"SlideIn_Top\"\n hideAnimation=\"SlideOut_Top\"\n animationDuration=\"0.2\"\n rectAlignment=\"UpperLeft\"\n offsetXY=\"420 -5\"\n height=\"90\"\n width=\"90\"\n onClick=\"onClick_toggleUi(updateNotification)\"\n image=\"FinnIcon\"\n tooltip=\"Update notification\"\n tooltipPosition=\"Right\"\n tooltipBackgroundColor=\"rgba(0,0,0,1)\"/\u003e\n\n\u003c!-- main notification window --\u003e\n\u003cTableLayout id=\"updateNotification\"\n active=\"false\"\n color=\"#000000\"\n outlineSize=\"2 2\"\n outline=\"grey\"\n showAnimation=\"SlideIn_Top\"\n hideAnimation=\"SlideOut_Top\"\n animationDuration=\"0.2\"\n rectAlignment=\"UpperLeft\"\n offsetXY=\"60 -5\"\n height=\"225\"\n width=\"350\"\u003e\n\n \u003c!-- Header --\u003e\n \u003cRow preferredHeight=\"50\"\u003e\n \u003cCell\u003e\n \u003cPanel padding=\"10 10 0 0\"\u003e\n \u003c!-- this part will be updated via script --\u003e\n \u003cText id=\"notificationHeader\"\n font=\"font_teutonic-arkham\"\n fontSize=\"30\"\n alignment=\"MiddleCenter\"\u003ePlaceholder\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- patch highlights --\u003e\n \u003cRow id=\"highlightRow\"\n preferredHeight=\"100\"\u003e\n \u003cCell\u003e\n \u003cPanel padding=\"15 15 0 7\"\u003e\n \u003c!-- this part will be updated via script --\u003e\n \u003cText id=\"releaseHighlightText\"\n resizeTextForBestFit=\"true\"\u003ePlaceholder\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- explanation --\u003e\n \u003cRow preferredHeight=\"25\"\u003e\n \u003cCell\u003e\n \u003cPanel padding=\"15 15 0 7\"\u003e\n \u003cText resizeTextForBestFit=\"true\"\u003eVisit the usual place to receive this update.\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Buttons: \"Don't show again\" and \"Close\" --\u003e\n \u003cRow preferredHeight=\"50\"\u003e\n \u003cCell\u003e\n \u003cHorizontalLayout minHeight=\"55\"\n flexibleHeight=\"0\"\n padding=\"10 10 5 10\"\n spacing=\"10\"\u003e\n \u003cButton class=\"bottomButtons\"\n onClick=\"onClick_notification(dontShowAgain)\"\u003eDon't show again\u003c/Button\u003e\n \u003cButton class=\"bottomButtons\"\n onClick=\"onClick_notification(close)\"\u003eClose\u003c/Button\u003e\n \u003c/HorizontalLayout\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\u003c/TableLayout\u003e\n\u003c!-- include Global/UpdateNotification.xml --\u003e\n\u003c!-- include Global/Global.xml --\u003e" -} \ No newline at end of file + "XmlUI": "\u003c!-- include Global/Global.xml --\u003e\n\u003cDefaults\u003e\n \u003c!-- general stuff --\u003e\n \u003cText color=\"white\"\n fontSize=\"18\"/\u003e\n\u003c/Defaults\u003e\n\n\u003c!-- include Global/BottomBar.xml --\u003e\n\u003cDefaults\u003e\n \u003cButton class=\"navbar\"\n tooltipPosition=\"Left\"\n tooltipBackgroundColor=\"rgba(0,0,0,1)\"\n color=\"clear\"/\u003e\n\u003c/Defaults\u003e\n\n\u003c!-- Buttons at the bottom right (height: n * 37 - 2) --\u003e\n\u003cVerticalLayout visibility=\"Admin\"\n color=\"#000000\"\n outlineSize=\"1 1\"\n outline=\"#303030\"\n rectAlignment=\"LowerRight\"\n width=\"35\"\n height=\"72\"\n offsetXY=\"-1 120\"\n spacing=\"2\"\u003e\n \u003cButton class=\"navbar\"\n icon=\"devourer\"\n tooltip=\"Downloadable Content\"\n onClick=\"onClick_toggleUi(downloadWindow)\"/\u003e\n \u003cButton class=\"navbar\"\n icon=\"option-gear\"\n tooltip=\"Options\"\n onClick=\"onClick_toggleUi(optionPanel)\"/\u003e\n\u003c/VerticalLayout\u003e\n\n\u003c!-- Navigation Overlay button (not visibly to Grey and Black) --\u003e\n\u003cPanel visibility=\"White|Brown|Red|Orange|Yellow|Green|Teal|Blue|Purple|Pink\"\n color=\"#000000\"\n outlineSize=\"1 1\"\n outline=\"#303030\"\n rectAlignment=\"LowerRight\"\n width=\"35\"\n height=\"35\"\n offsetXY=\"-1 85\"\u003e\n \u003cButton class=\"navbar\"\n icon=\"NavigationOverlayIcon\"\n tooltip=\"Navigation Overlay\"\n onClick=\"onClick_toggleUi(Navigation Overlay)\"/\u003e\n\u003c/Panel\u003e\n\u003c!-- include Global/BottomBar.xml --\u003e\n\u003c!-- include Global/DownloadWindow.xml --\u003e\n\u003cDefaults\u003e\n \u003cButton class=\"downloadTab\"\n hoverClass=\"bGrey\"\n pressClass=\"bWhite\"\n onClick=\"onClick_tab\"\n color=\"#888888\"\n fontSize=\"24\"\n font=\"font_teutonic-arkham\"/\u003e\n \u003cButton class=\"bGrey\"\n color=\"grey\"/\u003e\n \u003cButton class=\"bWhite\"\n color=\"white\"/\u003e\n \u003cButton class=\"activeTab\"\n color=\"#ffffff\"/\u003e\n \u003cButton class=\"windowButton\"\n hoverClass=\"bGrey\"\n pressClass=\"bWhite\"\n selectClass=\"bWhite\"\n color=\"#888888\"\n font=\"font_teutonic-arkham\"/\u003e\n\u003c/Defaults\u003e\n\n\u003c!-- window to select downloadable content --\u003e\n\u003cVerticalLayout id=\"downloadWindow\"\n color=\"black\"\n active=\"false\"\n height=\"800\"\n width=\"900\"\n outlineSize=\"2 2\"\n outline=\"#303030\"\u003e\n\n \u003c!-- window header --\u003e\n \u003cPanel preferredHeight=\"60\"\n padding=\"10 10 5 5\"\n spacing=\"10\"\n outlineSize=\"2 2\"\n outline=\"#303030\"\n color=\"black\"\u003e\n \u003cText fontSize=\"32\"\n font=\"font_teutonic-arkham\"\n preferredWidth=\"600\"\n alignment=\"MiddleLeft\"\u003eDownloadable Content\u003c/Text\u003e\n \u003cButton id=\"downloadAll_button\"\n class=\"windowButton\"\n visibility=\"Black\"\n onClick=\"onClick_downloadAll\"\n height=\"30\"\n preferredWidth=\"110\"\n fontSize=\"20\"\n tooltip=\"Very rough estimate: 400 MB\"\n tooltipPosition=\"Above\"\n tooltipBackgroundColor=\"rgba(0,0,0,1)\"\u003eDownload Everything\u003c/Button\u003e\n \u003cButton id=\"spawnPlaceholder_button\"\n class=\"windowButton\"\n visibility=\"Black\"\n onClick=\"onClick_spawnPlaceholder\"\n height=\"30\"\n preferredWidth=\"110\"\n fontSize=\"20\"\u003eSpawn Placeholder\u003c/Button\u003e\n \u003cPanel preferredWidth=\"50\"\u003e\n \u003cButton rectAlignment=\"MiddleRight\"\n width=\"50\"\n color=\"clear\"\n icon=\"close\"\n tooltip=\"Close\"\n tooltipPosition=\"Right\"\n tooltipBackgroundColor=\"rgba(0,0,0,1)\"\n onClick=\"onClick_toggleUi(downloadWindow)\"/\u003e\n \u003c/Panel\u003e\n \u003c/Panel\u003e\n\n \u003cHorizontalLayout\u003e\n \u003cVerticalLayout preferredWidth=\"600\"\u003e\n \u003c!-- tab selection --\u003e\n \u003cHorizontalLayout preferredHeight=\"60\"\n padding=\"5\"\n spacing=\"5\"\u003e\n \u003cButton class=\"downloadTab activeTab\"\n id=\"tab1\"\u003eOfficial Campaigns\u003c/Button\u003e\n \u003cButton class=\"downloadTab\"\n id=\"tab2\"\u003eOfficial Scenarios\u003c/Button\u003e\n \u003cButton class=\"downloadTab\"\n id=\"tab3\"\u003eFan-Made Campaigns\u003c/Button\u003e\n \u003cButton class=\"downloadTab\"\n id=\"tab4\"\u003eFan-Made Scenarios\u003c/Button\u003e\n \u003cButton class=\"downloadTab\"\n id=\"tab5\"\u003eFan-Made Player Cards\u003c/Button\u003e\n \u003c/HorizontalLayout\u003e\n\n \u003c!-- content list --\u003e\n \u003cVerticalScrollView color=\"transparent\"\n minHeight=\"100\"\n flexibleHeight=\"100\"\n scrollSensitivity=\"27\"\n scrollbarColors=\"grey|grey|#C8C8C8|rgba(0.78,0.78,0.78,0.5)\"\n horizontalScrollbarVisibility=\"AutohideAndExpandViewport\"\n raycastTarget=\"true\"\u003e\n \u003cVerticalLayout id=\"contentList\"\n padding=\"10 25 0 0\"\u003e\n \u003c!-- this will be filled via scripting --\u003e\n \u003c/VerticalLayout\u003e\n \u003c/VerticalScrollView\u003e\n \u003c/VerticalLayout\u003e\n\n \u003c!-- content preview window --\u003e\n \u003cVerticalLayout preferredWidth=\"300\"\n padding=\"15 15 15 5\"\u003e\n\n \u003c!-- header --\u003e\n \u003cVerticalLayout preferredHeight=\"110\"\u003e\n \u003cText id=\"previewTitle\"\n fontSize=\"28\"\n preferredHeight=\"70\"\n font=\"font_teutonic-arkham\"\u003ePreviewTitle\u003c/Text\u003e\n \u003cText id=\"previewAuthor\"\n fontSize=\"20\"\n preferredHeight=\"40\"\n font=\"font_teutonic-arkham\"\u003eby PreviewAuthor\u003c/Text\u003e\n \u003c/VerticalLayout\u003e\n\n \u003c!-- box art --\u003e\n \u003cPanel id=\"previewArtPanel\"\n preferredHeight=\"390\"\u003e\n \u003cMask id=\"previewArtMask\"\u003e\n \u003c!-- image will be set via scripting --\u003e\n \u003cImage id=\"previewArtImage\" /\u003e\n \u003c/Mask\u003e\n \u003c/Panel\u003e\n\n \u003c!-- description --\u003e\n \u003cPanel preferredHeight=\"160\"\u003e\n \u003cText id=\"previewDescription\"\n alignment=\"UpperLeft\"\n resizeTextForBestFit=\"true\"\n resizeTextMinSize=\"12\"\n resizeTextMaxSize=\"18\"\u003ePreviewDescription\u003c/Text\u003e\n \u003c/Panel\u003e\n\n \u003c!-- download button / progress bar (visibility handled by lua code)--\u003e\n \u003cPanel preferredHeight=\"60\"\u003e\n \u003c!-- download button --\u003e\n \u003cButton id=\"download_button\"\n class=\"windowButton\"\n onClick=\"onClick_download\"\n height=\"50\"\n width=\"270\"\n fontSize=\"28\"\u003eDownload\u003c/Button\u003e\n \u003c!-- download progress bar --\u003e\n \u003cProgressBar id=\"download_progress\"\n active=\"false\"\n height=\"50\"\n width=\"270\"\n percentage=\"0\"\n color=\"#111111\"\n textColor=\"#aaaaaa\"\n fillImageColor=\"#333333\"/\u003e\n \u003c/Panel\u003e\n \u003c/VerticalLayout\u003e\n \u003c/HorizontalLayout\u003e\n\u003c/VerticalLayout\u003e\n\u003c!-- include Global/DownloadWindow.xml --\u003e\n\u003c!-- include Global/PlayAreaGallery.xml --\u003e\n\u003cDefaults\u003e\n \u003c!-- type selection at the top --\u003e\n \u003cButton class=\"imageTab\"\n hoverClass=\"bGrey\"\n pressClass=\"bWhite\"\n onClick=\"b7b45b/onClick_imageTab\"\n color=\"#888888\"\n fontSize=\"24\"\n font=\"font_teutonic-arkham\"/\u003e\n \u003cButton class=\"bGrey\"\n color=\"grey\"/\u003e\n \u003cButton class=\"bWhite\"\n color=\"white\"/\u003e\n\n \u003cButton class=\"windowButton\"\n hoverClass=\"bGrey\"\n pressClass=\"bWhite\"\n selectClass=\"bWhite\"\n color=\"#888888\"\n font=\"font_teutonic-arkham\"/\u003e\n\n \u003c!-- image boxes in the grid --\u003e\n \u003cVerticalLayout class=\"imageBox\"\n color=\"black\"\n outline=\"#303030\"\n outlineSize=\"2 2\"\n onClick=\"b7b45b/onClick_image\"/\u003e\n \u003cImage class=\"playareaImage\"\n preferredHeight=\"330\"/\u003e\n \u003cText class=\"imageName\"\n preferredHeight=\"40\"\n resizeTextForBestFit=\"true\"\n resizeTextMinSize=\"10\"\n resizeTextMaxSize=\"18\"/\u003e\n\n \u003c!-- item selection on the left --\u003e\n \u003cText class=\"itemText\"\n alignment=\"MiddleLeft\"/\u003e\n \u003cPanel class=\"itemPanel\"\n preferredHeight=\"45\"\n onClick=\"b7b45b/onClick_listItem\"/\u003e\n\n \u003c!-- other --\u003e\n \u003cText class=\"headerText\"\n fontSize=\"35\"/\u003e\n \u003cVerticalLayout childForceExpandHeight=\"false\"/\u003e\n\u003c/Defaults\u003e\n\n\u003cVerticalLayout id=\"playAreaGallery\"\n active=\"false\"\n color=\"black\"\n height=\"880\"\n width=\"900\"\n outlineSize=\"2 2\"\n outline=\"#303030\"\u003e\n\n \u003c!-- window header --\u003e\n \u003cPanel preferredHeight=\"60\"\n padding=\"10 10 5 5\"\n spacing=\"10\"\n outlineSize=\"2 2\"\n outline=\"#303030\"\n color=\"black\"\u003e\n \u003cText fontSize=\"32\"\n font=\"font_teutonic-arkham\"\n preferredWidth=\"600\"\n alignment=\"MiddleLeft\"\u003ePlayarea Image Gallery\u003c/Text\u003e\n \u003cButton id=\"customUrl_button\"\n class=\"windowButton\"\n onClick=\"onClick_customUrl\"\n height=\"30\"\n preferredWidth=\"125\"\n fontSize=\"24\"\u003eUse custom URL\u003c/Button\u003e\n \u003cPanel preferredWidth=\"50\"\u003e\n \u003cButton rectAlignment=\"MiddleRight\"\n width=\"50\"\n color=\"clear\"\n icon=\"close\"\n tooltip=\"Close\"\n tooltipPosition=\"Right\"\n tooltipBackgroundColor=\"rgba(0,0,0,1)\"\n onClick=\"onClick_toggleUi(playAreaGallery)\"/\u003e\n \u003c/Panel\u003e\n \u003c/Panel\u003e\n\n \u003c!-- tab selection --\u003e\n \u003cHorizontalLayout preferredHeight=\"60\"\n padding=\"5\"\n spacing=\"5\"\u003e\n \u003cButton class=\"imageTab\"\n id=\"imageTab1\"\u003eOfficial Campaigns\u003c/Button\u003e\n \u003cButton class=\"imageTab\"\n id=\"imageTab2\"\u003eOfficial Scenarios\u003c/Button\u003e\n \u003cButton class=\"imageTab\"\n id=\"imageTab3\"\u003eFan-Made Campaigns\u003c/Button\u003e\n \u003cButton class=\"imageTab\"\n id=\"imageTab4\"\u003eFan-Made Scenarios\u003c/Button\u003e\n \u003cButton class=\"imageTab\"\n id=\"imageTab5\"\u003eOther Images\u003c/Button\u003e\n \u003c/HorizontalLayout\u003e\n\n \u003cHorizontalLayout preferredHeight=\"760\"\u003e\n \u003c!-- left column: navigation bar --\u003e\n \u003cVerticalLayout id=\"itemSelection\"\n preferredWidth=\"180\"\n padding=\"10 15 0 0\"\u003e\n \u003c!-- this will be filled via scripting --\u003e\n \u003c!-- \u003cPanel class=\"itemPanel\"\u003e\n \u003cText class=\"itemText\"\u003eItem\u003c/Text\u003e\n \u003c/Panel\u003e --\u003e\n \u003c/VerticalLayout\u003e\n\n \u003c!-- right column: image gallery --\u003e\n \u003cVerticalScrollView color=\"transparent\"\n minHeight=\"100\"\n flexibleHeight=\"100\"\n preferredWidth=\"720\"\n scrollSensitivity=\"380\"\n scrollbarColors=\"grey|grey|#C8C8C8|rgba(0.78,0.78,0.78,0.5)\"\n horizontalScrollbarVisibility=\"AutohideAndExpandViewport\"\n raycastTarget=\"true\"\u003e\n \u003cGridLayout id=\"playareaList\"\n preferredWidth=\"700\"\n padding=\"25 25 5 5\"\n spacing=\"10\"\n cellSize=\"330 370\"\u003e\n \u003c!-- this will be filled via scripting --\u003e\n \u003c!-- \u003cVerticalLayout class=\"imageBox\"\u003e\n \u003cImage class=\"playareaImage\" image=\"\"/\u003e\n \u003cText class=\"imageName\"\u003eImage Name\u003c/Text\u003e\n \u003c/VerticalLayout\u003e --\u003e\n \u003c/GridLayout\u003e\n \u003c/VerticalScrollView\u003e\n \u003c/HorizontalLayout\u003e\n\u003c/VerticalLayout\u003e\n\u003c!-- include Global/PlayAreaGallery.xml --\u003e\n\u003c!-- include Global/TitleSplash.xml --\u003e\n\u003c!-- Title Splash when starting a scenario --\u003e\n\u003cPanel id=\"title_splash\"\n height=\"220\"\n position=\"0 250 0\"\n showAnimation=\"FadeIn\"\n hideAnimation=\"FadeOut\"\n active=\"false\"\n animationDuration=\"2\"\u003e\n \u003cImage id=\"title_gradient\"\n height=\"220\"\n image=\"TitleGradient\" /\u003e\n \u003cText id=\"title_splash_text\"\n width=\"95%\"\n height=\"180\"\n resizeTextForBestFit=\"true\"\n resizeTextMinSize=\"100\"\n resizeTextMaxSize=\"150\"\n font=\"font_teutonic-arkham\"\n outline=\"black\"\n outlineSize=\"3 -3\"\n horizontalOverflow=\"Overflow\"\u003e\n \u003c/Text\u003e\n\u003c/Panel\u003e\n\u003c!-- include Global/TitleSplash.xml --\u003e\n\u003c!-- include Global/NavigationOverlay.xml --\u003e\n\u003c!-- Default formatting --\u003e\n\u003cDefaults\u003e\n \u003cText color=\"#FFFFFF\"\n alignment=\"MiddleLeft\" /\u003e\n\n \u003cToggle isOn=\"False\"\n rectAlignment=\"MiddleRight\" /\u003e\n\n \u003cCell dontUseTableCellBackground=\"true\"\n outlineSize=\"0 1\"\n outline=\"grey\" /\u003e\n\n \u003c!-- options --\u003e\n \u003cRow class=\"nav_option-text\"\n preferredHeight=\"45\"/\u003e\n \u003cCell class=\"nav_option-text\"\n color=\"#333333\"/\u003e\n \u003cCell class=\"nav_option-button\"\n color=\"#333333\"/\u003e\n \u003cText class=\"nav_option-header\"\n fontSize=\"20\"\n font=\"font_teutonic-arkham\"/\u003e\n \u003cCell class=\"claim\"\n tooltip=\"Clicking this seat in the navigation overlay\u0026#xA;will now only swap the playercolor for you.\"\n tooltipPosition=\"Right\" /\u003e\n\n \u003c!-- buttons at the bottom --\u003e\n \u003cButton class=\"bottomButtons\"\n hoverClass=\"hover\"\n pressClass=\"press\"\n selectClass=\"select\"\n color=\"#888888\"\n minHeight=\"35\"\n fontSize=\"24\"\n font=\"font_teutonic-arkham\"/\u003e\n \u003cButton class=\"hover\"\n color=\"grey\"/\u003e\n \u003cButton class=\"press\"\n color=\"white\"/\u003e\n \u003cButton class=\"select\"\n color=\"white\"/\u003e\n\n \u003c!-- Navigation Panels --\u003e\n \u003cPanel class=\"navPanel\"\n active=\"false\"\n allowDragging=\"true\"\n rectAlignment=\"LowerRight\"\n returnToOriginalPositionWhenReleased=\"false\"\n offsetXY=\"-40 0\"\u003e\n \u003c/Panel\u003e\n\u003c/Defaults\u003e\n\n\u003c!-- full Panel --\u003e\n\u003cPanel id=\"navPanelFull\"\n height=\"358\"\n width=\"455\"\n class=\"navPanel\"\u003e\n\u003c/Panel\u003e\n\n\u003c!-- Play Area only --\u003e\n\u003cPanel id=\"navPanelPlay\"\n height=\"208\"\n width=\"205\"\n class=\"navPanel\"\u003e\n\u003c/Panel\u003e\n\n\u003c!-- Settings --\u003e\n\u003cTableLayout id=\"navPanelSettings\"\n active=\"false\"\n width=\"300\"\n height=\"380\"\n color=\"#000000\"\n outlineSize=\"2 2\"\n outline=\"grey\"\n rectAlignment=\"MiddleCenter\"\u003e\n\n \u003c!-- Header --\u003e\n \u003cRow preferredHeight=\"60\"\u003e\n \u003cCell\u003e\n \u003cPanel padding=\"10 0 0 0\"\u003e\n \u003cText font=\"font_teutonic-arkham\"\n fontSize=\"35\"\u003eNavigation Overlay\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Options --\u003e\n \u003cRow\u003e\n \u003cCell\u003e\n \u003cTableLayout columnWidths=\"0 125\"\n autoCalculateHeight=\"1\"\n cellPadding=\"10 0 5 5\"\u003e\n\n \u003c!-- Option: Custom pitch --\u003e\n \u003cRow class=\"nav_option-text\"\u003e\n \u003cCell class=\"nav_option-text\"\u003e\n \u003cText class=\"nav_option-header\"\u003eViewing angle in degrees:\u003c/Text\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"nav_option-button\"\u003e\n \u003cSlider id=\"sliderPitch\"\n onValueChanged=\"797ede/updatePitch\"\n wholeNumbers=\"true\"\n minValue=\"0\"\n maxValue=\"89\"\n value=\"75\"\n tooltip=\"This controls the camera pitch\u0026#xA;('nodding your head').\"\n tooltipPosition=\"Right\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: Custom distance --\u003e\n \u003cRow class=\"nav_option-text\"\u003e\n \u003cCell class=\"nav_option-text\"\u003e\n \u003cText class=\"nav_option-header\"\u003eViewing distance (relative):\u003c/Text\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"nav_option-button\"\u003e\n \u003cSlider id=\"sliderDistance\"\n onValueChanged=\"797ede/updateDistance\"\n wholeNumbers=\"true\"\n minValue=\"50\"\n maxValue=\"200\"\n value=\"100\"\n tooltip=\"This controls the camera distance\u0026#xA;(from 50% to 200% of the default settings).\"\n tooltipPosition=\"Right\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: Claim White --\u003e\n \u003cRow class=\"nav_option-text\"\u003e\n \u003cCell class=\"nav_option-text\"\u003e\n \u003cText class=\"nav_option-header\"\u003eClaim \"White\" seat\u003c/Text\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"nav_option-button claim\"\u003e\n \u003cToggle id=\"claimWhite\"\n onValueChanged=\"797ede/claimColor(White)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: Claim Orange --\u003e\n \u003cRow class=\"nav_option-text\"\u003e\n \u003cCell class=\"nav_option-text\"\u003e\n \u003cText class=\"nav_option-header\"\u003eClaim \"Orange\" seat\u003c/Text\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"nav_option-button claim\"\u003e\n \u003cToggle id=\"claimOrange\"\n onValueChanged=\"797ede/claimColor(Orange)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: Claim Green --\u003e\n \u003cRow class=\"nav_option-text\"\u003e\n \u003cCell class=\"nav_option-text\"\u003e\n \u003cText class=\"nav_option-header\"\u003eClaim \"Green\" seat\u003c/Text\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"nav_option-button claim\"\u003e\n \u003cToggle id=\"claimGreen\"\n onValueChanged=\"797ede/claimColor(Green)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: Claim Red --\u003e\n \u003cRow class=\"nav_option-text\"\u003e\n \u003cCell class=\"nav_option-text\"\u003e\n \u003cText class=\"nav_option-header\"\u003eClaim \"Red\" seat\u003c/Text\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"nav_option-button claim\"\u003e\n \u003cToggle id=\"claimRed\"\n onValueChanged=\"797ede/claimColor(Red)\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n \u003c/TableLayout\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Buttons: Defaults and Close --\u003e\n \u003cRow preferredHeight=\"50\"\u003e\n \u003cCell\u003e\n \u003cHorizontalLayout minHeight=\"55\"\n flexibleHeight=\"0\"\n padding=\"10 10 5 10\"\n spacing=\"35\"\u003e\n \u003cButton class=\"bottomButtons\"\n onClick=\"797ede/loadDefaultSettings\"\u003eLoad defaults\u003c/Button\u003e\n \u003cButton class=\"bottomButtons\"\n onClick=\"797ede/toggleSettings\"\u003eClose\u003c/Button\u003e\n \u003c/HorizontalLayout\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\u003c/TableLayout\u003e\n\u003c!-- include Global/NavigationOverlay.xml --\u003e\n\u003c!-- include Global/OptionPanel.xml --\u003e\n\u003c!-- Default formatting --\u003e\n\u003cDefaults\u003e\n \u003cText color=\"#FFFFFF\"\n alignment=\"MiddleLeft\"/\u003e\n\n \u003cDropdown rectAlignment=\"MiddleCenter\"/\u003e\n\n \u003cCell dontUseTableCellBackground=\"true\"\n outlineSize=\"0 1\"\n outline=\"grey\"/\u003e\n\n \u003c!-- main window --\u003e\n \u003cTableLayout class=\"window\"\n width=\"500\"\n height=\"800\"\n active=\"false\"\n color=\"#000000\"\n outlineSize=\"2 2\"\n outline=\"grey\"\n showAnimation=\"SlideIn_Right\"\n hideAnimation=\"SlideOut_Right\"\n animationDuration=\"0.2\"/\u003e\n\n \u003c!-- group headers --\u003e\n \u003cRow class=\"group-header\"\n preferredHeight=\"44\"/\u003e\n \u003cCell class=\"group-header\"\n padding=\"10 10 0 0\"\n columnSpan=\"3\"\n color=\"#222222\"/\u003e\n \u003cPanel class=\"group-header\"\n padding=\"5 0 0 0\"/\u003e\n \u003cText class=\"group-header\"\n fontSize=\"28\"\n font=\"font_teutonic-arkham\"/\u003e\n\n \u003c!-- options --\u003e\n \u003cRow class=\"option-text\"\n preferredHeight=\"50\"\n tooltipPosition=\"Left\"\n tooltipBackgroundColor=\"rgba(0,0,0,1)\"/\u003e\n \u003cCell class=\"option-text\"\n padding=\"10 10 5 5\"\n color=\"#333333\"\n columnSpan=\"2\"/\u003e\n \u003cCell class=\"option-button\"\n padding=\"10 10 5 5\"\n color=\"#333333\"/\u003e\n \u003cCell class=\"option-singleColumn\"\n padding=\"10 10 5 5\"\n color=\"#333333\"\n columnSpan=\"1\"/\u003e\n \u003cCell class=\"option-doubleColumn\"\n padding=\"10 10 5 5\"\n color=\"#333333\"\n columnSpan=\"2\"/\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\n padding=\"10 0 0 0\"/\u003e\n \u003cText class=\"option-header\"\n fontSize=\"22\"\n font=\"font_teutonic-arkham\"/\u003e\n \u003cPanel class=\"doubleColumn-wrapper\"\n padding=\"0 17 3 3\"/\u003e\n \u003cButton class=\"optionToggle\"\n image=\"option-off\"\n rectAlignment=\"MiddleRight\"\n offsetXY=\"-30 0\"\n colors=\"#FFFFFF|#dfdfdf\"\n height=\"36\"\n width=\"65\"\n ignoreLayout=\"True\"/\u003e\n\n \u003c!-- buttons at the bottom --\u003e\n \u003cButton class=\"bottomButtons\"\n hoverClass=\"hover\"\n pressClass=\"press\"\n selectClass=\"select\"\n color=\"#888888\"\n minHeight=\"35\"\n fontSize=\"24\"\n font=\"font_teutonic-arkham\"/\u003e\n \u003cButton class=\"hover\"\n color=\"grey\"/\u003e\n \u003cButton class=\"press\"\n color=\"white\"/\u003e\n \u003cButton class=\"select\"\n color=\"white\"/\u003e\n\u003c/Defaults\u003e\n\n\u003c!-- Option Panel --\u003e\n\u003cTableLayout id=\"optionPanel\"\n class=\"window\"\n rectAlignment=\"LowerRight\"\n offsetXY=\"-50 80\"\n raycastTarget=\"true\"\u003e\n \u003c!-- Header: Options --\u003e\n \u003cRow preferredHeight=\"60\"\u003e\n \u003cCell\u003e\n \u003cPanel padding=\"10 0 0 0\"\u003e\n \u003cText font=\"font_teutonic-arkham\"\n fontSize=\"35\"\u003eOptions\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Scrollable part with options --\u003e\n \u003cRow\u003e\n \u003cCell\u003e\n \u003cVerticalScrollView horizontalScrollbarVisibility=\"AutohideAndExpandViewport\"\n scrollSensitivity=\"30\"\n raycastTarget=\"true\"\u003e\n \u003cTableLayout columnWidths=\"0 100 75\"\n autoCalculateHeight=\"1\"\n useGlobalCellPadding=\"false\"\u003e\n\n \u003c!-- Group: general settings --\u003e\n \u003cRow class=\"group-header\"\u003e\n \u003cCell class=\"group-header\"\u003e\n \u003cPanel class=\"group-header\"\n image=\"header_acolyte\"\u003e\n \u003cText class=\"group-header\"\u003eGENERAL SETTINGS\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: card language --\u003e\n \u003c!-- disabled until we have the backend in place\n \u003cRow class=\"option-text\" tooltip=\"Downloading a campaign or importing a deck will use\u0026#xA;this language for cards (NOT FUNCTIONAL YET!).\"\u003e\n \u003cCell class=\"option-singleColumn\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eCard language\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-doubleColumn\"\u003e\n \u003cPanel class=\"doubleColumn-wrapper\"\u003e\n \u003cDropdown id=\"cardLanguage\" onValueChanged=\"languageSelected(selectedIndex)\"\u003e\n \u003cOption\u003e简体中文\u003c/Option\u003e\n \u003cOption\u003e繁體中文\u003c/Option\u003e\n \u003cOption\u003eDeutsch\u003c/Option\u003e\n \u003cOption\u003eEnglish\u003c/Option\u003e\n \u003cOption\u003eEspañol\u003c/Option\u003e\n \u003cOption\u003eFrançais\u003c/Option\u003e\n \u003cOption\u003eItaliano\u003c/Option\u003e\n \u003c/Dropdown\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e --\u003e\n\n \u003c!-- Option: splash scenario name on setup --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Fade in the name of the scenario for 2 seconds\u0026#xA;when placing down a scenario.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eShow scenario title on setup\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cButton class=\"optionToggle\"\n id=\"showTitleSplash\"\n onClick=\"onClick_toggleOption\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Group: play area settings --\u003e\n \u003cRow class=\"group-header\"\u003e\n \u003cCell class=\"group-header\"\u003e\n \u003cPanel class=\"group-header\"\n image=\"header_compass\"\u003e\n \u003cText class=\"group-header\"\u003ePLAY AREA SETTINGS\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: play area snap tags --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Only cards with the tag 'Location' will snap (official cards are supported by default).\u0026#xA;Disable this if you are having issues with custom content.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eEnable snap tags\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cButton class=\"optionToggle\"\n id=\"playAreaSnapTags\"\n onClick=\"onClick_toggleOption\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: location connections --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Automatically draw location connections based on card metadata.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eDraw location connections\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cButton class=\"optionToggle\"\n id=\"playAreaConnections\"\n onClick=\"onClick_toggleOption\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: play area connection color --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"This color will be used to draw lines\u0026#xA;for location connections.\"\u003e\n \u003cCell class=\"option-singleColumn\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eChoose color for location connections\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-doubleColumn\"\u003e\n \u003cPanel class=\"doubleColumn-wrapper\"\u003e\n \u003cButton id=\"playAreaConnectionColor\"\n onClick=\"onClick_playAreaConnectionColor\"\u003e\n \u003c/Button\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: change custom playarea image on setup --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Attempts to set the play area to a fitting image\u0026#xA;from the play area image gallery.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eChange background on setup\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cButton class=\"optionToggle\"\n id=\"changePlayAreaImage\"\n onClick=\"onClick_toggleOption\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Group: playermat settings --\u003e\n \u003cRow class=\"group-header\"\u003e\n \u003cCell class=\"group-header\"\u003e\n \u003cPanel class=\"group-header\"\n image=\"header_cover\"\u003e\n \u003cText class=\"group-header\"\u003ePLAYERMAT SETTINGS\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: enable snap tags --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Only cards with the tag 'Asset' will snap (official cards are supported by default).\u0026#xA;Disable this if you are having issues with custom content.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eEnable snap tags\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cButton class=\"optionToggle\"\n id=\"useSnapTags\"\n onClick=\"onClick_toggleOption\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: show draw 1 button --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Displays a button below the 'Upkeep' button that draws a card from your deck.\u0026#xA;Useful for multi-handed solo play.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eShow \"Draw 1\" button\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cButton class=\"optionToggle\"\n id=\"showDrawButton\"\n onClick=\"onClick_toggleOption\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: use clickable clue-counters --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Instead of automatically counting clues in the respective area on your playermat,\u0026#xA;this displays a clickable counter for clues.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eUse clickable clue counters\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cButton class=\"optionToggle\"\n id=\"useClueClickers\"\n onClick=\"onClick_toggleOption\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: use clickable resource counters --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"This enables spawning of clickable resource tokens for player cards.\u0026#xA;(Chef's Selection = assets with 0 uses)\"\u003e\n \u003cCell class=\"option-singleColumn\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eUse clickable resource tokens\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-doubleColumn\"\u003e\n \u003cPanel class=\"doubleColumn-wrapper\"\u003e\n \u003cDropdown id=\"useResourceCounters\"\n onValueChanged=\"resourceCounterSelected(selectedIndex)\"\u003e\n \u003cOption\u003eEnabled\u003c/Option\u003e\n \u003cOption\u003eChef's Selection\u003c/Option\u003e\n \u003cOption\u003eDisabled\u003c/Option\u003e\n \u003c/Dropdown\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: remove a player mat --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Remove an unused playermat for more table space.\u0026#xA;Displayed are the default colors.\"\u003e\n \u003cCell class=\"option-singleColumn\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eRemove a playermat\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-doubleColumn\"\u003e\n \u003cPanel class=\"doubleColumn-wrapper\"\u003e\n \u003cDropdown id=\"removePlayermat\"\n onValueChanged=\"playermatRemovalSelected(selectedIndex)\"\u003e\n \u003cOption\u003eClick to select\u003c/Option\u003e\n \u003cOption\u003e1: White\u003c/Option\u003e\n \u003cOption\u003e2: Orange\u003c/Option\u003e\n \u003cOption\u003e3: Green\u003c/Option\u003e\n \u003cOption\u003e4: Red\u003c/Option\u003e\n \u003c/Dropdown\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Group: fan-made accessories --\u003e\n \u003cRow class=\"group-header\"\u003e\n \u003cCell class=\"group-header\"\u003e\n \u003cPanel class=\"group-header\"\n image=\"header_olive\"\u003e\n \u003cText class=\"group-header\"\u003eFAN-MADE ACCESSORIES\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: show attachment helper --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Provides a card-sized bag for cards that are attached to other cards\u0026#xA;(e.g. Backpack).\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eAttachment Helper\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cButton class=\"optionToggle\"\n id=\"showAttachmentHelper\"\n onClick=\"onClick_toggleOption\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: show clean up helper --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Useful for campaign-play:\u0026#xA;It resets play areas to allow continuous gameplay in the same savegame.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eClean Up Helper\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cButton class=\"optionToggle\"\n id=\"showCleanUpHelper\"\n onClick=\"onClick_toggleOption\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: show CYOA campaign guides --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Displays in a 'Choose Your Own Adventure'\u0026#xA;style redesigned campaign guides.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eCYOA Campaign Guides\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cButton class=\"optionToggle\"\n id=\"showCYOA\"\n onClick=\"onClick_toggleOption\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: show displacement tool --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"This allows moving all objects on the main play area\u0026#xA;in a chosen direction.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eDisplacement Tool\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cButton class=\"optionToggle\"\n id=\"showDisplacementTool\"\n onClick=\"onClick_toggleOption\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: show hand helper --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Never count your hand cards again! This tool does that for you\u0026#xA;and additionally enables easy discarding of random cards.\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eHand Helper\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cButton class=\"optionToggle\"\n id=\"showHandHelper\"\n onClick=\"onClick_toggleOption\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Option: show search assistant --\u003e\n \u003cRow class=\"option-text\"\n tooltip=\"Quickly search 3, 6, 9 or the top X\u0026#xA;cards of your deck!\"\u003e\n \u003cCell class=\"option-text\"\u003e\n \u003cPanel class=\"singleColumn-wrapper\"\u003e\n \u003cText class=\"option-header\"\u003eSearch Assistant\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003cCell class=\"option-button\"\u003e\n \u003cButton class=\"optionToggle\"\n id=\"showSearchAssistant\"\n onClick=\"onClick_toggleOption\"/\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n \u003c/TableLayout\u003e\n \u003c/VerticalScrollView\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Buttons: Defaults and Close --\u003e\n \u003cRow preferredHeight=\"50\"\u003e\n \u003cCell\u003e\n \u003cHorizontalLayout minHeight=\"55\"\n flexibleHeight=\"0\"\n padding=\"10 10 5 10\"\n spacing=\"225\"\u003e\n \u003cButton class=\"bottomButtons\"\n onClick=\"onClick_defaultSettings\"\u003eLoad defaults\u003c/Button\u003e\n \u003cButton class=\"bottomButtons\"\n onClick=\"onClick_toggleUi(optionPanel)\"\u003eClose\u003c/Button\u003e\n \u003c/HorizontalLayout\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\u003c/TableLayout\u003e\n\u003c!-- include Global/OptionPanel.xml --\u003e\n\u003c!-- include Global/UpdateNotification.xml --\u003e\n\u003c!-- Default formatting inherented from OptionPanel! --\u003e\n\n\u003c!-- Icon with Finn, which can be clicked --\u003e\n\u003cImage id=\"FinnIcon\"\n active=\"false\"\n showAnimation=\"SlideIn_Top\"\n hideAnimation=\"SlideOut_Top\"\n animationDuration=\"0.2\"\n rectAlignment=\"UpperLeft\"\n offsetXY=\"420 -5\"\n height=\"90\"\n width=\"90\"\n onClick=\"onClick_toggleUi(updateNotification)\"\n image=\"FinnIcon\"\n tooltip=\"Update notification\"\n tooltipPosition=\"Right\"\n tooltipBackgroundColor=\"rgba(0,0,0,1)\"/\u003e\n\n\u003c!-- main notification window --\u003e\n\u003cTableLayout id=\"updateNotification\"\n active=\"false\"\n color=\"#000000\"\n outlineSize=\"2 2\"\n outline=\"grey\"\n showAnimation=\"SlideIn_Top\"\n hideAnimation=\"SlideOut_Top\"\n animationDuration=\"0.2\"\n rectAlignment=\"UpperLeft\"\n offsetXY=\"60 -5\"\n height=\"225\"\n width=\"350\"\u003e\n\n \u003c!-- Header --\u003e\n \u003cRow preferredHeight=\"50\"\u003e\n \u003cCell\u003e\n \u003cPanel padding=\"10 10 0 0\"\u003e\n \u003c!-- this part will be updated via script --\u003e\n \u003cText id=\"notificationHeader\"\n font=\"font_teutonic-arkham\"\n fontSize=\"30\"\n alignment=\"MiddleCenter\"\u003ePlaceholder\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- patch highlights --\u003e\n \u003cRow id=\"highlightRow\"\n preferredHeight=\"100\"\u003e\n \u003cCell\u003e\n \u003cPanel padding=\"15 15 0 7\"\u003e\n \u003c!-- this part will be updated via script --\u003e\n \u003cText id=\"releaseHighlightText\"\n resizeTextForBestFit=\"true\"\u003ePlaceholder\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- explanation --\u003e\n \u003cRow preferredHeight=\"25\"\u003e\n \u003cCell\u003e\n \u003cPanel padding=\"15 15 0 7\"\u003e\n \u003cText resizeTextForBestFit=\"true\"\u003eVisit the usual place to receive this update.\u003c/Text\u003e\n \u003c/Panel\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\n \u003c!-- Buttons: \"Don't show again\" and \"Close\" --\u003e\n \u003cRow preferredHeight=\"50\"\u003e\n \u003cCell\u003e\n \u003cHorizontalLayout minHeight=\"55\"\n flexibleHeight=\"0\"\n padding=\"10 10 5 10\"\n spacing=\"10\"\u003e\n \u003cButton class=\"bottomButtons\"\n onClick=\"onClick_notification(dontShowAgain)\"\u003eDon't show again\u003c/Button\u003e\n \u003cButton class=\"bottomButtons\"\n onClick=\"onClick_notification(close)\"\u003eClose\u003c/Button\u003e\n \u003c/HorizontalLayout\u003e\n \u003c/Cell\u003e\n \u003c/Row\u003e\n\u003c/TableLayout\u003e\n\u003c!-- include Global/UpdateNotification.xml --\u003e\n\u003c!-- include Global/Global.xml --\u003e" +}