-- Bundled by luabundle {"version":"1.6.0"} local __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire) local loadingPlaceholder = {[{}] = true} local register local modules = {} local require local loaded = {} register = function(name, body) if not modules[name] then modules[name] = body end end require = function(name) local loadedModule = loaded[name] if loadedModule then if loadedModule == loadingPlaceholder then return nil end else if not modules[name] then if not superRequire then local identifier = type(name) == 'string' and '\"' .. name .. '\"' or tostring(name) error('Tried to require ' .. identifier .. ', but no such module has been registered') else return superRequire(name) end end loaded[name] = loadingPlaceholder loadedModule = modules[name](require, loaded, register, modules) loaded[name] = loadedModule end return loadedModule end return require, loaded, register, modules end)(nil) __bundle_register("__root", function(require, _LOADED, __bundle_register, __bundle_modules) require("accessories/Subject5U-21Helper") end) __bundle_register("accessories/Subject5U-21Helper", function(require, _LOADED, __bundle_register, __bundle_modules) local searchLib = require("util/SearchLib") local classOrder = { "Guardian", "Seeker", "Survivor", "Mystic", "Rogue" } local bParam = {} bParam.width = 0 bParam.height = 0 bParam.function_owner = self bParam.click_function = "none" bParam.label = "0" bParam.position = {x = 0, y = 0.1, z = -0.7} bParam.scale = {x = 0.1, y = 0.1, z = 0.1} bParam.font_color = "White" bParam.font_size = 700 function onLoad() self.createButton({ width = 2750, height = 800, function_owner = self, click_function = "updateDisplayButtons", label = "Update!", tooltip = "Count classes from cards on this tile", position = {x = 0, y = 0.1, z = 0.875}, scale = {x = 0.1, y = 0.1, z = 0.1}, font_size = 500 }) createDisplayButtons() end function createDisplayButtons() local x_offset = 0.361 bParam.position.x = -3 * x_offset for i = 1, 5 do bParam.position.x = bParam.position.x + x_offset self.createButton(bParam) end end function updateDisplayButtons(_, playerColor) local classCount = { Guardian = 0, Seeker = 0, Survivor = 0, Mystic = 0, Rogue = 0, uncounted = 0 } -- loop through cards on this helper and count classes from metadata for _, notes in ipairs(getNotesFromCardsAndContainers()) do if notes.class then for str in string.gmatch(notes.class, "([^|]+)") do if not tonumber(classCount[str]) then str = "uncounted" end classCount[str] = classCount[str] + 1 end end end -- edit button labels with index 1-5 for i = 1, 5 do self.editButton({index = i, label = classCount[classOrder[i]]}) end -- show message about uncounted cards if classCount.uncounted > 0 then printToColor("Search included " .. classCount.uncounted .. " neutral/ununcounted card(s).", playerColor, "Orange") end end function getNotesFromCardsAndContainers() local notesList = {} for _, obj in ipairs(searchLib.onObject(self)) do local notes = {} if obj.type == "Card" then notes = JSON.decode(obj.getGMNotes()) or {} table.insert(notesList, notes) elseif obj.type == "Bag" or obj.type == "Deck" then -- check if there are actually objects contained and loop through them local containedObjects = obj.getData().ContainedObjects if containedObjects then for _, deepObj in ipairs(containedObjects) do if deepObj.Name == "Card" or deepObj.Name == "CardCustom" then notes = JSON.decode(deepObj.GMNotes) or {} table.insert(notesList, notes) end end end end end return notesList end end) __bundle_register("util/SearchLib", function(require, _LOADED, __bundle_register, __bundle_modules) do local SearchLib = {} local filterFunctions = { isCard = function(x) return x.type == "Card" end, isDeck = function(x) return x.type == "Deck" end, isCardOrDeck = function(x) return x.type == "Card" or x.type == "Deck" end, isClue = function(x) return x.memo == "clueDoom" and x.is_face_down == false end, isTileOrToken = function(x) return x.type == "Tile" end, isUniversalToken = function(x) return x.getMemo() == "universalActionAbility" end, } -- performs the actual search and returns a filtered list of object references ---@param pos tts__Vector Global position ---@param rot? tts__Vector Global rotation ---@param size table Size ---@param filter? string Name of the filter function ---@param direction? table Direction (positive is up) ---@param maxDistance? number Distance for the cast local function returnSearchResult(pos, rot, size, filter, direction, maxDistance) local filterFunc if filter then filterFunc = filterFunctions[filter] end local searchResult = Physics.cast({ origin = pos, direction = direction or { 0, 1, 0 }, orientation = rot or { 0, 0, 0 }, type = 3, size = size, max_distance = maxDistance or 0 }) -- filter the result for matching objects local objList = {} for _, v in ipairs(searchResult) do if not filter or filterFunc(v.hit_object) then table.insert(objList, v.hit_object) end end return objList end -- searches the specified area SearchLib.inArea = function(pos, rot, size, filter) return returnSearchResult(pos, rot, size, filter) end -- searches the area on an object SearchLib.onObject = function(obj, filter) local pos = obj.getPosition() local size = obj.getBounds().size:setAt("y", 1) return returnSearchResult(pos, _, size, filter) end -- searches the specified position (a single point) SearchLib.atPosition = function(pos, filter) local size = { 0.1, 2, 0.1 } return returnSearchResult(pos, _, size, filter) end -- searches below the specified position (downwards until y = 0) SearchLib.belowPosition = function(pos, filter) local size = { 0.1, 2, 0.1 } local direction = { 0, -1, 0 } local maxDistance = pos.y return returnSearchResult(pos, _, size, filter, direction, maxDistance) end return SearchLib end end) return __bundle_require("__root")