diff --git a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.ttslua b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.ttslua index 92d26084..2d63eb65 100644 --- a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.ttslua +++ b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.ttslua @@ -26,26 +26,17 @@ end function updateMemoryWithMoves() memoryList = memoryListBackup --get the first transposed object's coordinates - local obj = getObjectFromGUID(moveGuid) + local obj = getObjectFromGUID(moveGuid or "") -- p1 is where needs to go, p2 is where it was local refObjPos = memoryList[moveGuid].pos local deltaPos = findOffsetDistance(obj.getPosition(), refObjPos, nil) - local movedRotation = obj.getRotation() for guid, entry in pairs(memoryList) do memoryList[guid].pos.x = entry.pos.x - deltaPos.x memoryList[guid].pos.y = entry.pos.y - deltaPos.y memoryList[guid].pos.z = entry.pos.z - deltaPos.z - -- memoryList[guid].rot.x = movedRotation.x - -- memoryList[guid].rot.y = movedRotation.y - -- memoryList[guid].rot.z = movedRotation.z end - --theList[obj.getGUID()] = { - -- pos={x=round(pos.x,4), y=round(pos.y,4), z=round(pos.z,4)}, - -- rot={x=round(rot.x,4), y=round(rot.y,4), z=round(rot.z,4)}, - -- lock=obj.getLock() - --} moveList = {} end diff --git a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/StandaloneScenarios.77a5f9.ttslua b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/StandaloneScenarios.77a5f9.ttslua index 92d26084..2d63eb65 100644 --- a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/StandaloneScenarios.77a5f9.ttslua +++ b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/StandaloneScenarios.77a5f9.ttslua @@ -26,26 +26,17 @@ end function updateMemoryWithMoves() memoryList = memoryListBackup --get the first transposed object's coordinates - local obj = getObjectFromGUID(moveGuid) + local obj = getObjectFromGUID(moveGuid or "") -- p1 is where needs to go, p2 is where it was local refObjPos = memoryList[moveGuid].pos local deltaPos = findOffsetDistance(obj.getPosition(), refObjPos, nil) - local movedRotation = obj.getRotation() for guid, entry in pairs(memoryList) do memoryList[guid].pos.x = entry.pos.x - deltaPos.x memoryList[guid].pos.y = entry.pos.y - deltaPos.y memoryList[guid].pos.z = entry.pos.z - deltaPos.z - -- memoryList[guid].rot.x = movedRotation.x - -- memoryList[guid].rot.y = movedRotation.y - -- memoryList[guid].rot.z = movedRotation.z end - --theList[obj.getGUID()] = { - -- pos={x=round(pos.x,4), y=round(pos.y,4), z=round(pos.z,4)}, - -- rot={x=round(rot.x,4), y=round(rot.y,4), z=round(rot.z,4)}, - -- lock=obj.getLock() - --} moveList = {} end diff --git a/objects/OptionPanelSource.830bd0/CYOACampaignGuides.e87ea2.ttslua b/objects/OptionPanelSource.830bd0/CYOACampaignGuides.e87ea2.ttslua index 0c9a65d3..7aaa754e 100644 --- a/objects/OptionPanelSource.830bd0/CYOACampaignGuides.e87ea2.ttslua +++ b/objects/OptionPanelSource.830bd0/CYOACampaignGuides.e87ea2.ttslua @@ -243,26 +243,17 @@ end function updateMemoryWithMoves() memoryList = memoryListBackup --get the first transposed object's coordinates - local obj = getObjectFromGUID(moveGuid) + local obj = getObjectFromGUID(moveGuid or "") -- p1 is where needs to go, p2 is where it was local refObjPos = memoryList[moveGuid].pos local deltaPos = findOffsetDistance(obj.getPosition(), refObjPos, nil) - local movedRotation = obj.getRotation() for guid, entry in pairs(memoryList) do memoryList[guid].pos.x = entry.pos.x - deltaPos.x memoryList[guid].pos.y = entry.pos.y - deltaPos.y memoryList[guid].pos.z = entry.pos.z - deltaPos.z - -- memoryList[guid].rot.x = movedRotation.x - -- memoryList[guid].rot.y = movedRotation.y - -- memoryList[guid].rot.z = movedRotation.z end - --theList[obj.getGUID()] = { - -- pos={x=round(pos.x,4), y=round(pos.y,4), z=round(pos.z,4)}, - -- rot={x=round(rot.x,4), y=round(rot.y,4), z=round(rot.z,4)}, - -- lock=obj.getLock() - --} moveList = {} end @@ -809,4 +800,3 @@ end function AllMemoryBagsInScene:getGuidList() return Global.getTable(self.NAME_OF_GLOBAL_VARIABLE) or {} end - diff --git a/src/accessories/TokenArrangerApi.ttslua b/src/accessories/TokenArrangerApi.ttslua index fa33b4f7..c436c0e3 100644 --- a/src/accessories/TokenArrangerApi.ttslua +++ b/src/accessories/TokenArrangerApi.ttslua @@ -3,8 +3,8 @@ do local guidReferenceApi = require("core/GUIDReferenceApi") -- local function to call the token arranger, if it is on the table - ---@param functionName String Name of the function to cal - ---@param argument Variant Parameter to pass + ---@param functionName string Name of the function to cal + ---@param argument? table Parameter to pass local function callIfExistent(functionName, argument) local tokenArranger = guidReferenceApi.getObjectByOwnerAndType("Mythos", "TokenArranger") if tokenArranger ~= nil then @@ -13,7 +13,7 @@ do end -- updates the token modifiers with the provided data - ---@param fullData Table Contains the chaos token metadata + ---@param fullData table Contains the chaos token metadata TokenArrangerApi.onTokenDataChanged = function(fullData) callIfExistent("onTokenDataChanged", fullData) end diff --git a/src/arkhamdb/ArkhamDb.ttslua b/src/arkhamdb/ArkhamDb.ttslua index 841822fe..896cb03c 100644 --- a/src/arkhamdb/ArkhamDb.ttslua +++ b/src/arkhamdb/ArkhamDb.ttslua @@ -1,17 +1,17 @@ do local allCardsBagApi = require("playercards/AllCardsBagApi") local playAreaApi = require("core/PlayAreaApi") + + local ArkhamDb = {} + local internal = {} - local ArkhamDb = { } - local internal = { } + local tabooList = {} + local configuration local RANDOM_WEAKNESS_ID = "01000" - local tabooList = { } - --Forward declaration - ---@type Request + ---@class Request local Request = {} - local configuration -- Sets up the ArkhamDb interface. Should be called from the parent object on load. ArkhamDb.initialize = function() @@ -19,7 +19,6 @@ do Request.start({ configuration.api_uri, configuration.taboo }, function(status) local json = JSON.decode(internal.fixUtf16String(status.text)) for _, taboo in pairs(json) do - ---@type local cards = {} for _, card in pairs(JSON.decode(taboo.cards)) do @@ -37,18 +36,19 @@ do -- Start the deck build process for the given player color and deck ID. This -- will retrieve the deck from ArkhamDB, and pass to a callback for processing. - ---@param playerColor String. Color name of the player mat to place this deck on (e.g. "Red"). - ---@param deckId String. ArkhamDB deck id to be loaded - ---@param isPrivate Boolean. Whether this deck is published or private on ArkhamDB - ---@param loadNewest Boolean. Whether the newest version of this deck should be loaded - ---@param loadInvestigators Boolean. Whether investigator cards should be loaded as part of this - --- deck - ---@param callback Function. Callback which will be sent the results of this load. Parameters - --- to the callback will be: - --- slots Table. A map of card ID to count in the deck + ---@param playerColor string Color name of the player mat to place this deck on (e.g. "Red"). + ---@param deckId string ArkhamDB deck id to be loaded + ---@param isPrivate boolean Whether this deck is published or private on ArkhamDB + ---@param loadNewest boolean Whether the newest version of this deck should be loaded + ---@param loadInvestigators boolean Whether investigator cards should be loaded as part of this deck + ---@param callback function Callback which will be sent the results of this load + --- Parameters to the callback will be: + --- slots table A map of card ID to count in the deck --- investigatorCode String. ID of the investigator in this deck - --- customizations Table. The decoded table of customization upgrades in this deck + --- customizations table The decoded table of customization upgrades in this deck --- playerColor String. Color this deck is being loaded for + ---@return boolean + ---@return string ArkhamDb.getDecklist = function( playerColor, deckId, @@ -60,16 +60,19 @@ do -- the deck load. The called method will handle player notification. local checkCard = allCardsBagApi.getCardById("01001") if (checkCard ~= nil and checkCard.data == nil) then - return + return false, "Indexing not complete" end - local deckUri = { configuration.api_uri, - isPrivate and configuration.private_deck or configuration.public_deck, deckId } + local deckUri = { + configuration.api_uri, + isPrivate and configuration.private_deck or configuration.public_deck, + deckId + } local deck = Request.start(deckUri, function(status) if string.find(status.text, "") then internal.maybePrint("Private deck ID " .. deckId .. " is not shared", playerColor) - return false, table.concat({ "Private deck ", deckId, " is not shared" }) + return false, "Private deck " .. deckId .. " is not shared" end local json = JSON.decode(status.text) @@ -87,8 +90,8 @@ do -- Logs that a card could not be loaded in the mod by printing it to the console in the given -- color of the player owning the deck. Attempts to look up the name on ArkhamDB for clarity, -- but prints the card ID if the name cannot be retrieved. - ---@param cardId String. ArkhamDB ID of the card that could not be found - ---@param playerColor String. Color of the player's deck that had the problem + ---@param cardId string ArkhamDB ID of the card that could not be found + ---@param playerColor string Color of the player's deck that had the problem ArkhamDb.logCardNotFound = function(cardId, playerColor) local request = Request.start({ configuration.api_uri, @@ -113,18 +116,17 @@ do -- response then applies standard transformations to the deck such as adding -- random weaknesses and checking for taboos. Once the deck is processed, -- passes to loadCards to actually spawn the defined deck. - ---@param deck ArkhamImportDeck - ---@param playerColor String Color name of the player mat to place this deck on (e.g. "Red") - ---@param loadNewest Boolean Whether the newest version of this deck should be loaded - ---@param loadInvestigators Boolean Whether investigator cards should be loaded as part of this - --- deck - ---@param callback Function Callback which will be sent the results of this load. Parameters - --- to the callback will be: - --- slots Table. A map of card ID to count in the deck + ---@param deck table ArkhamImportDeck + ---@param playerColor string Color name of the player mat to place this deck on (e.g. "Red") + ---@param loadNewest boolean Whether the newest version of this deck should be loaded + ---@param loadInvestigators boolean Whether investigator cards should be loaded as part of this deck + ---@param callback function Callback which will be sent the results of this load. + --- Parameters to the callback will be: + --- slots table A map of card ID to count in the deck --- investigatorCode String. ID of the investigator in this deck --- bondedList A table of cardID keys to meaningless values. Card IDs in this list were --- added from a parent bonded card. - --- customizations Table. The decoded table of customization upgrades in this deck + --- customizations table The decoded table of customization upgrades in this deck --- playerColor String. Color this deck is being loaded for internal.onDeckResult = function(deck, playerColor, loadNewest, loadInvestigators, callback) -- Load the next deck in the upgrade path if the option is enabled @@ -165,9 +167,9 @@ do -- Checks to see if the slot list includes the random weakness ID. If it does, -- removes it from the deck and replaces it with the ID of a random basic weakness provided by the -- all cards bag - ---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number + ---@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 - ---@param playerColor String Color of the player this deck is being loaded for. Used for broadcast + ---@param playerColor string Color of the player this deck is being loaded for. Used for broadcast --- if a weakness is added. internal.maybeDrawRandomWeakness = function(slots, playerColor) local randomWeaknessAmount = slots[RANDOM_WEAKNESS_ID] or 0 @@ -183,8 +185,8 @@ do end -- Adds both the investigator (XXXXX) and minicard (XXXXX-m) slots with one copy each - ---@param deck Table The processed ArkhamDB deck response - ---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the + ---@param deck table The processed ArkhamDB deck response + ---@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 ---@return string: Contains the name of the art that should be loaded ("normal", "promo" or "revised") internal.addInvestigatorCards = function(deck, slots) @@ -238,7 +240,7 @@ do end -- Process the card list looking for the customizable cards, and add their upgrade sheets if needed - ---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number + ---@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 internal.maybeAddUpgradeSheets = function(slots) for cardId, _ in pairs(slots) do @@ -252,7 +254,7 @@ do -- Process the card list looking for the Summoned Servitor, and add its minicard to the list if -- needed - ---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number + ---@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 internal.maybeAddSummonedServitor = function(slots) if slots["09080"] ~= nil then @@ -262,9 +264,9 @@ do -- On the Mend should have 1-per-investigator copies set aside, but ArkhamDB always sends 1. Update -- the count based on the investigator count - ---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number + ---@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 - ---@param playerColor String Color of the player this deck is being loaded for. Used for broadcast if an error occurs + ---@param playerColor string Color of the player this deck is being loaded for. Used for broadcast if an error occurs internal.maybeAddOnTheMend = function(slots, playerColor) if slots["09006"] ~= nil then local investigatorCount = playAreaApi.getInvestigatorCount() @@ -278,7 +280,7 @@ do end -- Process the card list looking for Reality Acid and adds the reference sheet when needed - ---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number + ---@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 internal.maybeAddRealityAcidReference = function(slots) if slots["89004"] ~= nil then @@ -287,8 +289,8 @@ do end -- Processes the deck description from ArkhamDB and modifies the slot list accordingly - ---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number - ---@param description String The deck desription from ArkhamDB + ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number + ---@param description string The deck desription from ArkhamDB internal.maybeModifyDeckFromDescription = function(slots, description) -- check for import instructions local pos = string.find(description, "++SCED import instructions++") @@ -331,7 +333,7 @@ do end -- Process the slot list and looks for any cards which are bonded to those in the deck. Adds those cards to the slot list. - ---@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 + ---@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 internal.extractBondedCards = function(slots) -- Create a list of bonded cards first so we don't modify slots while iterating local bondedCards = { } @@ -362,8 +364,8 @@ do end -- 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") - ---@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 - ---@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 + ---@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 + ---@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 internal.checkTaboos = function(tabooId, slots, playerColor) if tabooId then for cardId, _ in pairs(tabooList[tabooId].cards) do @@ -391,9 +393,9 @@ do end -- Gets the ArkhamDB config info from the configuration object. - ---@return Table. Configuration data + ---@return table: configuration data internal.getConfiguration = function() - local configuration = getObjectsWithTag("import_configuration_provider")[1]:getTable("configuration") + local configuation = getObjectsWithTag("import_configuration_provider")[1].getTable("configuration") printPriority = configuration.priority return configuration end @@ -404,15 +406,14 @@ do end) end - ---@type Request Request = { is_done = false, is_successful = false } - -- Creates a new instance of a Request. Should not be directly called. Instead use Request.start and Request.deferred. - ---@param uri string - ---@param configure fun(request: Request, status: WebRequestStatus) + -- Creates a new instance of a Request. Should not be directly called. Instead use Request.start() and Request.deferred(). + ---@param uri table + ---@param configure fun(request, status) ---@return Request function Request:new(uri, configure) local this = {} @@ -425,20 +426,16 @@ do end this.uri = uri - - WebRequest.get(uri, function(status) - configure(this, status) - end) + WebRequest.get(uri, function(status) configure(this, status) end) return this end -- Creates a new request. on_success should set the request's is_done, is_successful, and content variables. -- 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) - ---@param uri string - ---@param on_success fun(request: Request, status: WebRequestStatus, vararg any) - ---@param on_error fun(status: WebRequestStatus)|nil - ---@vararg any[] + ---@param uri table + ---@param on_success fun(request, status, vararg) + ---@param on_error fun(status)|nil ---@return Request function Request.deferred(uri, on_success, on_error, ...) local parameters = table.pack(...) @@ -455,11 +452,11 @@ do end) end - -- Creates a new request. on_success should return weather the resultant data is as expected, and the processed content of the request. - ---@param uri string - ---@param on_success fun(status: WebRequestStatus, vararg any): boolean, any - ---@param on_error nil|fun(status: WebRequestStatus, vararg any): string - ---@vararg any[] + -- Creates a new request. on_success should return whether the resultant data is as expected, and the processed content of the request. + ---@param uri table + ---@param on_success fun(status, vararg): boolean, any + ---@param on_error nil|fun(status, vararg): string + ---@vararg any ---@return Request function Request.start(uri, on_success, on_error, ...) local parameters = table.pack(...) @@ -472,17 +469,14 @@ do end ---@param requests Request[] - ---@param on_success fun(content: any[], vararg any[]) - ---@param on_error fun(requests: Request[], vararg any[])|nil + ---@param on_success fun(content: any, vararg: any) + ---@param on_error fun(requests: Request, vararg: any)|nil ---@vararg any function Request.with_all(requests, on_success, on_error, ...) local parameters = table.pack(...) Wait.condition(function() - ---@type any[] local results = {} - - ---@type Request[] local errors = {} for _, request in ipairs(requests) do @@ -510,7 +504,6 @@ do end) end - ---@param callback fun(content: any, vararg any) function Request:with(callback, ...) local arguments = table.pack(...) Wait.condition(function() diff --git a/src/arkhamdb/Configuration.ttslua b/src/arkhamdb/Configuration.ttslua index f0120788..29ef3c36 100644 --- a/src/arkhamdb/Configuration.ttslua +++ b/src/arkhamdb/Configuration.ttslua @@ -1,4 +1,4 @@ ----@type ArkhamImportConfiguration +---@type table Contains fields used by the deck importer configuration = { api_uri = "https://arkhamdb.com/api/public", public_deck = "decklist", diff --git a/src/arkhamdb/DeckImporterApi.ttslua b/src/arkhamdb/DeckImporterApi.ttslua index 8628b6c4..537986c1 100644 --- a/src/arkhamdb/DeckImporterApi.ttslua +++ b/src/arkhamdb/DeckImporterApi.ttslua @@ -6,16 +6,18 @@ do return guidReferenceApi.getObjectByOwnerAndType("Mythos", "DeckImporter") end + ---@class uiStateTable + ---@field redDeck string Deck ID to load for the red player + ---@field orangeDeck string Deck ID to load for the orange player + ---@field whiteDeck string Deck ID to load for the white player + ---@field greenDeck string Deck ID to load for the green player + ---@field privateDeck boolean True to load a private deck, false to load a public deck + ---@field loadNewest boolean True if the most upgraded version of the deck should be loaded + ---@field investigators boolean True if investigator cards should be spawned + -- Returns a table with the full state of the UI, including options and deck IDs. -- This can be used to persist via onSave(), or provide values for a load operation - -- Table values: - -- redDeck: Deck ID to load for the red player - -- orangeDeck: Deck ID to load for the orange player - -- whiteDeck: Deck ID to load for the white player - -- greenDeck: Deck ID to load for the green player - -- private: True to load a private deck, false to load a public deck - -- loadNewest: True if the most upgraded version of the deck should be loaded - -- investigators: True if investigator cards should be spawned + ---@return uiStateTable uiStateTable Contains data about the current UI state DeckImporterApi.getUiState = function() local passthroughTable = {} for k,v in pairs(getDeckImporter().call("getUiState")) do @@ -25,15 +27,7 @@ do end -- Updates the state of the UI based on the provided table. Any values not provided will be left the same. - ---@param uiStateTable Table of values to update on importer - -- Table values: - -- redDeck: Deck ID to load for the red player - -- orangeDeck: Deck ID to load for the orange player - -- whiteDeck: Deck ID to load for the white player - -- greenDeck: Deck ID to load for the green player - -- private: True to load a private deck, false to load a public deck - -- loadNewest: True if the most upgraded version of the deck should be loaded - -- investigators: True if investigator cards should be spawned + ---@return uiStateTable uiStateTable Contains data about the current UI state DeckImporterApi.setUiState = function(uiStateTable) return getDeckImporter().call("setUiState", uiStateTable) end diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index 1c77edaa..d909081c 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -18,8 +18,8 @@ end function onSave() return JSON.encode(getUiState()) end -- Returns the zone name where the specified card should be placed, based on its metadata. ----@param cardMetadata Table of card metadata. ----@return Zone String Name of the zone such as "Deck", "SetAside1", etc. +---@param cardMetadata table Contains card metadata +---@return string Zone Name of the zone such as "Deck", "SetAside1", etc. -- See Zones object documentation for a list of valid zones. function getDefaultCardZone(cardMetadata, bondedList) if (cardMetadata.id == "09080-m") then -- Have to check the Servitor before other minicards @@ -59,7 +59,7 @@ function buildDeck(playerColor, deckId) arkhamDb.getDecklist( playerColor, deckId, - uiState.private, + uiState.privateDeck, uiState.loadNewest, uiState.investigators, loadCards) @@ -70,17 +70,17 @@ end -- This is a callback function which handles the results of ArkhamDb.getDecklist() -- This method uses an encapsulated coroutine with yields to make the card spawning cleaner. -- ----@param slots Table Key-Value table of cardId:count. cardId is the ArkhamDB ID of the card to spawn, +---@param slots table Key-Value table of cardId:count. cardId is the ArkhamDB ID of the card to spawn, -- and count is the number which should be spawned ----@param investigatorId String ArkhamDB ID (code) for this deck's investigator. +---@param investigatorId string ArkhamDB ID (code) for this deck's investigator. -- Investigator cards should already be added to the slots list if they -- should be spawned, but this value is separate to check for special -- handling for certain investigators ----@param bondedList Table A table of cardID keys to meaningless values. Card IDs in this list were added +---@param bondedList table A table of cardID keys to meaningless values. Card IDs in this list were added -- from a parent bonded card. ----@param customizations String ArkhamDB data for customizations on customizable cards ----@param playerColor String Color name of the player mat to place this deck on (e.g. "Red") ----@param loadAltInvestigator String Contains the name of alternative art for the investigator ("normal", "revised" or "promo") +---@param customizations string ArkhamDB data for customizations on customizable cards +---@param playerColor string Color name of the player mat to place this deck on (e.g. "Red") +---@param loadAltInvestigator string Contains the name of alternative art for the investigator ("normal", "revised" or "promo") function loadCards(slots, investigatorId, bondedList, customizations, playerColor, loadAltInvestigator) function coinside() local cardsToSpawn = {} @@ -162,8 +162,8 @@ end -- Callback handler for the main deck spawning. Looks for cards which should start in hand, and -- draws them for the appropriate player. ----@param deck Object Callback-provided spawned deck object ----@param playerColor String Color of the player to draw the cards to +---@param deck tts__Object Callback-provided spawned deck object +---@param playerColor string Color of the player to draw the cards to function deckSpawned(deck, playerColor) local player = Player[playmatApi.getPlayerColor(playerColor)] local handPos = player.getHandTransform(1).position -- Only one hand zone per player @@ -185,7 +185,7 @@ end -- Converts the Raven Quill's selections from card IDs to card names. This could be more elegant -- but the inputs are very static so we're using some brute force. ----@param selectionString String provided by ArkhamDB, indicates the customization selections +---@param selectionString string provided by ArkhamDB, indicates the customization selections -- Should be either a single card ID or two separated by a ^ (e.g. XXXXX^YYYYY) function convertRavenQuillSelections(selectionString) if (string.len(selectionString) == 5) then @@ -196,7 +196,7 @@ function convertRavenQuillSelections(selectionString) end -- Converts Grizzled's selections from a single string with "^". ----@param selectionString String provided by ArkhamDB, indicates the customization selections +---@param selectionString string provided by ArkhamDB, indicates the customization selections -- Should be two Traits separated by a ^ (e.g. XXXXX^YYYYY) function convertGrizzledSelections(selectionString) return selectionString:gsub("%^", ", ") @@ -217,8 +217,8 @@ function getCardName(cardId) end -- Split a single list of cards into a separate table of lists, keyed by the zone ----@param cards Table Table of {cardData, cardMetadata, zone} ----@return: Table of {zoneName=card list} +---@param cards table Table of {cardData, cardMetadata, zone} +---@return table ZoneNames Table with zoneName as index: {zoneName=card list} function buildZoneLists(cards) local zoneList = {} for _, card in ipairs(cards) do @@ -232,7 +232,7 @@ function buildZoneLists(cards) end -- Check to see if the deck list has Ancestral Knowledge. If it does, move 5 random skills to SetAside3 ----@param cardList Table Deck list being created +---@param cardList table Deck list being created function handleAncestralKnowledge(cardList) local hasAncestralKnowledge = false local skillList = {} @@ -258,8 +258,8 @@ function handleAncestralKnowledge(cardList) end -- Check for and handle Underworld Market by moving all Illicit cards to UnderSetAside3 ----@param cardList Table Deck list being created ----@param playerColor String Color this deck is being loaded for +---@param cardList table Deck list being created +---@param playerColor string Color this deck is being loaded for function handleUnderworldMarket(cardList, playerColor) local hasMarket = false local illicitList = {} @@ -276,9 +276,7 @@ function handleUnderworldMarket(cardList, playerColor) if hasMarket then if #illicitList < 10 then - printToAll("Only " .. #illicitList .. - " Illicit cards in your deck, you can't trigger Underworld Market's ability.", - playerColor) + printToAll("Only " .. #illicitList .. " Illicit cards in your deck, you can't trigger Underworld Market's ability.", playerColor) else -- Process cards to move them to the market deck. This is done in reverse -- order because the sorting needs to be reversed (deck sorts for face down) @@ -293,9 +291,7 @@ function handleUnderworldMarket(cardList, playerColor) end if #illicitList > 10 then - printToAll("Moved all " .. #illicitList .. - " Illicit cards to the Market deck, reduce it to 10", - playerColor) + printToAll("Moved all " .. #illicitList .. " Illicit cards to the Market deck, reduce it to 10", playerColor) else printToAll("Built the Market deck", playerColor) end @@ -303,12 +299,11 @@ function handleUnderworldMarket(cardList, playerColor) end end --- If the investigator is Joe Diamond, extract all Insight events to SetAside5 to build the Hunch --- Deck. ----@param investigatorId String ID for the deck's investigator card. Passed separately because the +-- If the investigator is Joe Diamond, extract all Insight events to SetAside5 to build the Hunch Deck +---@param investigatorId string ID for the deck's investigator card. Passed separately because the --- investigator may not be included in the cardList ----@param cardList Table Deck list being created ----@param playerColor String Color this deck is being loaded for +---@param cardList table Deck list being created +---@param playerColor string Color this deck is being loaded for function handleHunchDeck(investigatorId, cardList, playerColor) if investigatorId == "05002" then -- Joe Diamond local insightList = {} @@ -343,12 +338,11 @@ function handleHunchDeck(investigatorId, cardList, playerColor) end end --- If the investigator is Parallel Jim Culver, extract all Ally assets to SetAside5 to build the Spirit --- Deck. ----@param investigatorId String ID for the deck's investigator card. Passed separately because the +-- If the investigator is Parallel Jim Culver, extract all Ally assets to SetAside5 to build the Spirit Deck +---@param investigatorId string ID for the deck's investigator card. Passed separately because the --- investigator may not be included in the cardList ----@param cardList Table Deck list being created ----@param playerColor String Color this deck is being loaded for +---@param cardList table Deck list being created +---@param playerColor string Color this deck is being loaded for function handleSpiritDeck(investigatorId, cardList, playerColor) if investigatorId == "02004-p" or investigatorId == "02004-pb" then -- Parallel Jim Culver local spiritList = {} @@ -387,8 +381,8 @@ end -- For any customization upgrade cards in the card list, process the metadata from the deck to -- set the save state to show the correct checkboxes/text field values ----@param cardList Table Deck list being created ----@param customizations String ArkhamDB data for customizations on customizable cards +---@param cardList table Deck list being created +---@param customizations string ArkhamDB data for customizations on customizable cards function handleCustomizableUpgrades(cardList, customizations) for _, card in ipairs(cardList) do if card.metadata.type == "UpgradeSheet" then @@ -457,9 +451,9 @@ function handleCustomizableUpgrades(cardList, customizations) end -- Handles cards that start in play under specific conditions for Ashcan Pete (Regular Pete - Duke, Parallel Pete - Guitar) ----@param investigatorId String ID for the deck's investigator card. Passed separately because the +---@param investigatorId string ID for the deck's investigator card. Passed separately because the --- investigator may not be included in the cardList ----@param cardList Table Deck list being created +---@param cardList table Deck list being created function handlePeteSignatureAssets(investigatorId, cardList) if investigatorId == "02005" or investigatorId == "02005-pb" then -- regular Pete's front for i, card in ipairs(cardList) do @@ -477,8 +471,8 @@ function handlePeteSignatureAssets(investigatorId, cardList) end -- Callback function for investigator cards and minicards to set the correct state for alt art ----@param card Object Card which needs to be set the state for ----@param loadAltInvestigator String Contains the name of alternative art for the investigator ("normal", "revised" or "promo") +---@param card tts__Object Card which needs to be set the state for +---@param loadAltInvestigator string Contains the name of alternative art for the investigator ("normal", "revised" or "promo") function loadAltArt(card, loadAltInvestigator) -- states are set up this way: -- 1 - normal, 2 - revised/promo, 3 - promo (if 2 is revised) diff --git a/src/arkhamdb/DeckImporterUi.ttslua b/src/arkhamdb/DeckImporterUi.ttslua index 892c087b..5788446d 100644 --- a/src/arkhamdb/DeckImporterUi.ttslua +++ b/src/arkhamdb/DeckImporterUi.ttslua @@ -27,36 +27,21 @@ local loadInvestigators = false -- Returns a table with the full state of the UI, including options and deck IDs. -- This can be used to persist via onSave(), or provide values for a load operation --- Table values: --- redDeck: Deck ID to load for the red player --- orangeDeck: Deck ID to load for the orange player --- whiteDeck: Deck ID to load for the white player --- greenDeck: Deck ID to load for the green player --- private: True to load a private deck, false to load a public deck --- loadNewest: True if the most upgraded version of the deck should be loaded --- investigators: True if investigator cards should be spawned +---@return uiStateTable uiStateTable Contains data about the current UI state function getUiState() return { redDeck = redDeckId, orangeDeck = orangeDeckId, whiteDeck = whiteDeckId, greenDeck = greenDeckId, - private = privateDeck, + privateDeck = privateDeck, loadNewest = loadNewestDeck, investigators = loadInvestigators } end -- Updates the state of the UI based on the provided table. Any values not provided will be left the same. ----@param uiStateTable Table of values to update on importer --- Table values: --- redDeck: Deck ID to load for the red player --- orangeDeck: Deck ID to load for the orange player --- whiteDeck: Deck ID to load for the white player --- greenDeck: Deck ID to load for the green player --- private: True to load a private deck, false to load a public deck --- loadNewest: True if the most upgraded version of the deck should be loaded --- investigators: True if investigator cards should be spawned +---@param uiStateTable table Table of values to update on importer function setUiState(uiStateTable) self.clearButtons() self.clearInputs() @@ -70,7 +55,7 @@ function initializeUi(savedUiState) orangeDeckId = savedUiState.orangeDeck whiteDeckId = savedUiState.whiteDeck greenDeckId = savedUiState.greenDeck - privateDeck = savedUiState.private + privateDeck = savedUiState.privateDeck loadNewestDeck = savedUiState.loadNewest loadInvestigators = savedUiState.investigators end diff --git a/src/chaosbag/BlessCurseManager.ttslua b/src/chaosbag/BlessCurseManager.ttslua index c1e3e623..e0cecbaa 100644 --- a/src/chaosbag/BlessCurseManager.ttslua +++ b/src/chaosbag/BlessCurseManager.ttslua @@ -63,7 +63,6 @@ function initializeState() -- count tokens in the bag local chaosBag = chaosBagApi.findChaosBag() - local tokens = {} for _, v in ipairs(chaosBag.getObjects()) do if v.name == "Bless" then numInPlay.Bless = numInPlay.Bless + 1 @@ -207,9 +206,10 @@ end --------------------------------------------------------- -- returns a formatted string with information about the provided token type (bless / curse) +---@param type string Type of chaos token ("Bless" or "Curse") +---@param omitBrackets? boolean Controls whether the brackets should be omitted from the return +---@return string tokenCount function formatTokenCount(type, omitBrackets) - if type == nil then type = mode end - if omitBrackets then return (numInPlay[type] - #tokensTaken[type]) .. " + " .. #tokensTaken[type] else @@ -218,7 +218,7 @@ function formatTokenCount(type, omitBrackets) end -- seals a token on a card (called by cards that seal bless/curse tokens) ----@param param Table This contains the type and guid of the sealed token +---@param param table This contains the type and guid of the sealed token function sealedToken(param) table.insert(tokensTaken[param.type], param.guid) broadcastCount(param.type) @@ -226,7 +226,7 @@ function sealedToken(param) end -- returns a token to the bag (called by cards that seal bless/curse tokens) ----@param param Table This contains the type and guid of the released token +---@param param table This contains the type and guid of the released token function releasedToken(param) for i, v in ipairs(tokensTaken[param.type]) do if v == param.guid then @@ -238,7 +238,7 @@ function releasedToken(param) end -- removes a token (called by cards that seal bless/curse tokens) ----@param param Table This contains the type and guid of the released token +---@param param table This contains the type and guid of the released token function returnedToken(param) for i, v in ipairs(tokensTaken[param.type]) do if v == param.guid then diff --git a/src/chaosbag/BlessCurseManagerApi.ttslua b/src/chaosbag/BlessCurseManagerApi.ttslua index 74b42440..fa347b86 100644 --- a/src/chaosbag/BlessCurseManagerApi.ttslua +++ b/src/chaosbag/BlessCurseManagerApi.ttslua @@ -15,35 +15,41 @@ do end -- updates the internal count (called by cards that seal bless/curse tokens) + ---@param type string Type of chaos token ("Bless" or "Curse") + ---@param guid string GUID of the token BlessCurseManagerApi.sealedToken = function(type, guid) getManager().call("sealedToken", { type = type, guid = guid }) end -- updates the internal count (called by cards that seal bless/curse tokens) + ---@param type string Type of chaos token ("Bless" or "Curse") + ---@param guid string GUID of the token BlessCurseManagerApi.releasedToken = function(type, guid) getManager().call("releasedToken", { type = type, guid = guid }) end -- updates the internal count (called by cards that seal bless/curse tokens) + ---@param type string Type of chaos token ("Bless" or "Curse") + ---@param guid string GUID of the token BlessCurseManagerApi.returnedToken = function(type, guid) getManager().call("returnedToken", { type = type, guid = guid }) end -- broadcasts the current status for bless/curse tokens - ---@param playerColor String Color of the player to show the broadcast to + ---@param playerColor string Color of the player to show the broadcast to BlessCurseManagerApi.broadcastStatus = function(playerColor) getManager().call("broadcastStatus", playerColor) end -- removes all bless / curse tokens from the chaos bag and play - ---@param playerColor String Color of the player to show the broadcast to + ---@param playerColor string Color of the player to show the broadcast to BlessCurseManagerApi.removeAll = function(playerColor) getManager().call("doRemove", playerColor) end -- adds bless / curse sealing to the hovered card - ---@param playerColor String Color of the player to show the broadcast to - ---@param hoveredObject TTSObject Hovered object + ---@param playerColor string Color of the player to show the broadcast to + ---@param hoveredObject tts__Object Hovered object BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject) getManager().call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject }) end diff --git a/src/chaosbag/ChaosBagApi.ttslua b/src/chaosbag/ChaosBagApi.ttslua index 58ebdf9e..33e63d4e 100644 --- a/src/chaosbag/ChaosBagApi.ttslua +++ b/src/chaosbag/ChaosBagApi.ttslua @@ -2,7 +2,7 @@ do local ChaosBagApi = {} -- respawns the chaos bag with a new state of tokens - ---@param tokenList Table List of chaos token ids + ---@param tokenList table List of chaos token ids ChaosBagApi.setChaosBagState = function(tokenList) return Global.call("setChaosBagState", tokenList) end @@ -29,29 +29,30 @@ do end -- returns all sealed tokens on cards to the chaos bag + ---@param playerColor string Color of the player to show the broadcast to ChaosBagApi.releaseAllSealedTokens = function(playerColor) return Global.call("releaseAllSealedTokens", playerColor) end -- returns all drawn tokens to the chaos bag - ChaosBagApi.returnChaosTokens = function(playerColor) - return Global.call("returnChaosTokens", playerColor) + ChaosBagApi.returnChaosTokens = function() + return Global.call("returnChaosTokens") end -- removes the specified chaos token from the chaos bag - ---@param id String ID of the chaos token + ---@param id string ID of the chaos token ChaosBagApi.removeChaosToken = function(id) return Global.call("removeChaosToken", id) end -- returns a chaos token to the bag and calls all relevant functions - ---@param token TTSObject Chaos Token to return + ---@param token tts__Object Chaos token to return ChaosBagApi.returnChaosTokenToBag = function(token) return Global.call("returnChaosTokenToBag", token) end -- spawns the specified chaos token and puts it into the chaos bag - ---@param id String ID of the chaos token + ---@param id string ID of the chaos token ChaosBagApi.spawnChaosToken = function(id) return Global.call("spawnChaosToken", id) end @@ -60,12 +61,14 @@ do -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the -- contents of the bag should check this method before doing so. -- This method will broadcast a message to all players if the bag is being searched. - ---@return Boolean. True if the bag is manipulated, false if it should be blocked. + ---@return any canTouch True if the bag is manipulated, false if it should be blocked. ChaosBagApi.canTouchChaosTokens = function() return Global.call("canTouchChaosTokens") end -- called by playermats (by the "Draw chaos token" button) + ---@param mat tts__Object Playermat that triggered this + ---@param drawAdditional boolean Controls whether additional tokens should be drawn ChaosBagApi.drawChaosToken = function(mat, drawAdditional) return Global.call("drawChaosToken", {mat = mat, drawAdditional = drawAdditional}) end diff --git a/src/core/GUIDReferenceApi.ttslua b/src/core/GUIDReferenceApi.ttslua index 63db9288..2d7d1584 100644 --- a/src/core/GUIDReferenceApi.ttslua +++ b/src/core/GUIDReferenceApi.ttslua @@ -5,29 +5,31 @@ do return getObjectFromGUID("123456") end - -- returns all matching objects as a table with references - ---@param owner String Parent object for this search - ---@param type String Type of object to search for + ---@param owner string Parent object for this search + ---@param type string Type of object to search for + ---@return any: Object reference to the matching object GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type) return getGuidHandler().call("getObjectByOwnerAndType", { owner = owner, type = type }) end -- returns all matching objects as a table with references - ---@param type String Type of object to search for + ---@param type string Type of object to search for + ---@return table: List of object references to matching objects GUIDReferenceApi.getObjectsByType = function(type) return getGuidHandler().call("getObjectsByType", type) end -- returns all matching objects as a table with references - ---@param owner String Parent object for this search + ---@param owner string Parent object for this search + ---@return table: List of object references to matching objects GUIDReferenceApi.getObjectsByOwner = function(owner) return getGuidHandler().call("getObjectsByOwner", owner) end -- sends new information to the reference handler to edit the main index - ---@param owner String Parent of the object - ---@param type String Type of the object - ---@param guid String GUID of the object + ---@param owner string Parent of the object + ---@param type string Type of the object + ---@param guid string GUID of the object GUIDReferenceApi.editIndex = function(owner, type, guid) return getGuidHandler().call("editIndex", { owner = owner, diff --git a/src/core/GameKeyHandler.ttslua b/src/core/GameKeyHandler.ttslua index 40994cc7..ad83b50a 100644 --- a/src/core/GameKeyHandler.ttslua +++ b/src/core/GameKeyHandler.ttslua @@ -333,8 +333,8 @@ function addBlurseSealingMenu(playerColor, hoveredObject) end -- Simple method to check if the given point is in a specified area ----@param point Vector Point to check, only x and z values are relevant ----@param bounds Table Defined area to see if the point is within +---@param point tts__Vector Point to check, only x and z values are relevant +---@param bounds table Defined area to see if the point is within function inArea(point, bounds) return (point.x > bounds.minX and point.x < bounds.maxX diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 86026fc0..6d3b3841 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -268,7 +268,7 @@ end -- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the -- contents of the bag should check this method before doing so. -- This method will broadcast a message to all players if the bag is being searched. ----@return Boolean. True if the bag is manipulated, false if it should be blocked. +---@return boolean: True if the bag is manipulated, false if it should be blocked. function canTouchChaosTokens() for color, searching in pairs(bagSearchers) do if searching then @@ -329,7 +329,7 @@ end -- DEPRECATED. Use TokenManager instead. -- Spawns a single token. ----@param params Table. Array with arguments to the method. 1 = position, 2 = type, 3 = rotation +---@param params table Array with arguments to the method. 1 = position, 2 = type, 3 = rotation function spawnToken(params) return tokenManager.spawnToken(params[1], params[2], params[3]) end @@ -416,7 +416,7 @@ end --------------------------------------------------------- -- called for button creation on the difficulty selectors ----@param args Table Parameters for this function: +---@param args table Parameters for this function: -- object TTSObject Usually "self" -- key String Name of the scenario function createSetupButtons(args) @@ -467,7 +467,7 @@ function createSetupButtons(args) end -- called for adding chaos tokens ----@param args Table Parameters for this function: +---@param args table Parameters for this function: -- object object Usually "self" -- key string Name of the scenario -- mode string difficulty (e.g. "hard" or "expert") @@ -567,7 +567,7 @@ function getChaosBagState() end -- respawns the chaos bag with a new state of tokens ----@param tokenList Table List of chaos token ids +---@param tokenList table List of chaos token ids ---@api ChaosBag / ChaosBagApi function setChaosBagState(tokenList) if not canTouchChaosTokens() then return end @@ -608,7 +608,7 @@ function setChaosBagState(tokenList) end -- spawns the specified chaos token and puts it into the chaos bag ----@param id String ID of the chaos token +---@param id string ID of the chaos token function spawnChaosToken(id) if not canTouchChaosTokens() then return end @@ -636,7 +636,7 @@ function spawnChaosToken(id) end -- removes the specified chaos token from the chaos bag ----@param id String ID of the chaos token +---@param id string ID of the chaos token function removeChaosToken(id) if not canTouchChaosTokens() then return end @@ -688,7 +688,7 @@ end --------------------------------------------------------- -- forwards the requested content type to the update function and sets highlight to clicked tab ----@param tabId String Id of the clicked tab +---@param tabId string Id of the clicked tab function onClick_tab(_, _, tabId) for listId, listContent in pairs(tabIdTable) do if listId == tabId then @@ -747,7 +747,7 @@ function onClick_download(player) end -- the download button on the placeholder objects calls this to directly initiate a download ----@param params Table contains url and guid of replacement object +---@param params table contains url and guid of replacement object function placeholder_download(params) local url = SOURCE_REPO .. '/' .. params.url requestObj = WebRequest.get(url, function (request) contentDownloadCallback(request, params) end) @@ -825,7 +825,7 @@ function coroutineDownloadAll() broadcastToAll("Downloading " .. contentType .. "...") local contained = "" for _, params in ipairs(objectList) do - local request = WebRequest.get(SOURCE_REPO .. '/' .. params.url) + local request = WebRequest.get(SOURCE_REPO .. '/' .. params.url, function() end) local start = os.time() while true do if request.is_done then @@ -908,8 +908,8 @@ function onClick_spawnPlaceholder() end -- toggles the visibility of the respective UI ----@param player LuaPlayer Player that triggered this ----@param title String Name of the UI to toggle +---@param player tts__Player Player that triggered this +---@param title string Name of the UI to toggle function onClick_toggleUi(player, title) if title == "Navigation Overlay" then navigationOverlayApi.cycleVisibility(player.color) @@ -1162,8 +1162,8 @@ function libraryDownloadCallback(request) end -- loops through an XML table and returns the specified object ----@param ui Table XmlTable (get this via getXmlTable) ----@param id String Id of the object to return +---@param ui table XmlTable (get this via getXmlTable) +---@param id string Id of the object to return function getXmlTableElementById(ui, id) for _, obj in ipairs(ui) do if obj.attributes and obj.attributes.id and obj.attributes.id == id then return obj end @@ -1251,7 +1251,7 @@ function playermatRemovalSelected(player, selectedIndex, id) end -- removes a playermat and all related objects from play ----@param matColor String Color of the playermat to remove +---@param matColor string Color of the playermat to remove function removePlayermat(matColor) local matObjects = guidReferenceApi.getObjectsByOwner(matColor) if not matObjects.Playermat then return end @@ -1290,8 +1290,8 @@ function updateOptionPanelState() end -- handles the applying of option selections and calls the respective functions based ----@param id String ID of the option that was selected or deselected ----@param state Boolean State of the option (true = enabled) +---@param id string ID of the option that was selected or deselected +---@param state boolean|any State of the option (true = enabled) function applyOptionPanelChange(id, state) -- option: Snap tags if id == "useSnapTags" then @@ -1366,7 +1366,7 @@ function applyOptionPanelChange(id, state) -- option: Show CYOA campaign guides elseif id == "showCYOA" then - optionPanel[id] = spawnOrRemoveHelper(state, "CYOA Campaign Guides", {39, 1.3, -20}) + optionPanel[id] = spawnOrRemoveHelper(state, "CYOA Campaign Guides", { 39, 1.3, -20}) -- option: Show displacement tool elseif id == "showDisplacementTool" then @@ -1375,12 +1375,12 @@ function applyOptionPanelChange(id, state) end -- handler for spawn / remove functions of helper objects ----@param state Boolean Contains the state of the option: true = spawn it, false = remove it ----@param name String Name of the helper object ----@param position Vector Position of the object (where it will spawn) ----@param rotation Vector Rotation of the object for spawning (default: {0, 270, 0}) ----@param owner String Owner of the object (defaults to "Mythos") ----@return. GUID of the spawnedObj (or nil if object was removed) +---@param state boolean Contains the state of the option: true = spawn it, false = remove it +---@param name string Name of the helper object +---@param position tts__Vector Position of the object (where it will spawn) +---@param rotation? tts__Vector Rotation of the object for spawning (default: {0, 270, 0}) +---@param owner? string Owner of the object (defaults to "Mythos") +---@return string|nil GUID GUID of the spawnedObj (or nil if object was removed) function spawnOrRemoveHelper(state, name, position, rotation, owner) if (type(state) == "table" and #state == 0) then return removeHelperObject(name) @@ -1396,9 +1396,9 @@ function spawnOrRemoveHelper(state, name, position, rotation, owner) end -- copies the specified tool (by name) from the option panel source bag ----@param name String Name of the object that should be copied ----@param position Table Desired position of the object ----@param rotation Table Desired rotation of the object (defaults to object's rotation) +---@param name string Name of the object that should be copied +---@param position tts__Vector Desired position of the object +---@param rotation? tts__Vector Desired rotation of the object (defaults to object's rotation) function spawnHelperObject(name, position, rotation) local sourceBag = guidReferenceApi.getObjectByOwnerAndType("Mythos","OptionPanelSource") @@ -1427,7 +1427,7 @@ function spawnHelperObject(name, position, rotation) end -- removes the specified tool (by name) ----@param name String Object that should be removed +---@param name string Object that should be removed function removeHelperObject(name) -- links objects name to the respective option name (to grab the GUID for removal) local referenceTable = { @@ -1457,6 +1457,8 @@ end -- loads saved options function loadSettings(newOptions) + -- TO-DO: instead of overriding, keep original table and only add new data + -- this will ensure that new options aren't set to nil when importing an old state optionPanel = newOptions updateOptionPanelState() for id, state in pairs(optionPanel) do @@ -1553,7 +1555,7 @@ function compareVersion(request) end -- converts a version number to a string ----@param version String Version number, separated by dots (e.g. 3.3.1) +---@param version string Version number, separated by dots (e.g. 3.3.1) function convertVersionToNumber(version) local major, minor, patch = string.match(version, "(%d+)%.(%d+)%.(%d+)") return major * 100 + minor * 10 + patch diff --git a/src/core/MythosArea.ttslua b/src/core/MythosArea.ttslua index 6cef6680..34ad046c 100644 --- a/src/core/MythosArea.ttslua +++ b/src/core/MythosArea.ttslua @@ -221,9 +221,9 @@ end --------------------------------------------------------- -- Simple method to check if the given point is in a specified area ----@param point Vector Point to check, only x and z values are relevant ----@param bounds Table Defined area to see if the point is within ----@return Boolean: True if the point is in the area defined by bounds +---@param point tts__Vector Point to check, only x and z values are relevant +---@param bounds table Defined area to see if the point is within +---@return boolean: True if the point is in the area defined by bounds function inArea(point, bounds) return (point.x < bounds.upperLeft.x and point.x > bounds.lowerRight.x diff --git a/src/core/MythosAreaApi.ttslua b/src/core/MythosAreaApi.ttslua index 325f22a5..a60291c0 100644 --- a/src/core/MythosAreaApi.ttslua +++ b/src/core/MythosAreaApi.ttslua @@ -6,17 +6,19 @@ do return guidReferenceApi.getObjectByOwnerAndType("Mythos", "MythosArea") end - -- returns the chaos token metadata (if provided through scenario reference card) + ---@return any: Table of chaos token metadata (if provided through scenario reference card) MythosAreaApi.returnTokenData = function() return getMythosArea().call("returnTokenData") end - -- returns an object reference to the encounter deck + ---@return any: Object reference to the encounter deck MythosAreaApi.getEncounterDeck = function() return getMythosArea().call("getEncounterDeck") end -- draw an encounter card for the requesting mat + ---@param mat tts__Object Playermat that triggered this + ---@param alwaysFaceUp boolean Whether the card should be drawn face-up MythosAreaApi.drawEncounterCard = function(mat, alwaysFaceUp) getMythosArea().call("drawEncounterCard", {mat = mat, alwaysFaceUp = alwaysFaceUp}) end diff --git a/src/core/NavigationOverlayApi.ttslua b/src/core/NavigationOverlayApi.ttslua index adfed08d..73b2a1a6 100644 --- a/src/core/NavigationOverlayApi.ttslua +++ b/src/core/NavigationOverlayApi.ttslua @@ -6,25 +6,25 @@ do return guidReferenceApi.getObjectByOwnerAndType("Mythos", "NavigationOverlayHandler") end - -- Copies the visibility for the Navigation overlay - ---@param startColor String Color of the player to copy from - ---@param targetColor String Color of the targeted player + -- copies the visibility for the Navigation overlay + ---@param startColor string Color of the player to copy from + ---@param targetColor string Color of the targeted player NavigationOverlayApi.copyVisibility = function(startColor, targetColor) getNOHandler().call("copyVisibility", { startColor = startColor, targetColor = targetColor }) - end + end - -- Changes the Navigation Overlay view ("Full View" --> "Play Areas" --> "Closed" etc.) - ---@param playerColor String Color of the player to update the visibility for + -- changes the Navigation Overlay view ("Full View" --> "Play Areas" --> "Closed" etc.) + ---@param playerColor string Color of the player to update the visibility for NavigationOverlayApi.cycleVisibility = function(playerColor) getNOHandler().call("cycleVisibility", playerColor) end -- loads the specified camera for a player - ---@param player TTSPlayerInstance Player whose camera should be moved - ---@param camera Variant If number: Index of the camera view to load | If string: Color of the playermat to swap to + ---@param player tts__Player Player whose camera should be moved + ---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to NavigationOverlayApi.loadCamera = function(player, camera) getNOHandler().call("loadCameraFromApi", { player = player, diff --git a/src/core/NavigationOverlayHandler.ttslua b/src/core/NavigationOverlayHandler.ttslua index f20beedc..21a09a3d 100644 --- a/src/core/NavigationOverlayHandler.ttslua +++ b/src/core/NavigationOverlayHandler.ttslua @@ -236,7 +236,7 @@ end -- handles all button clicks function buttonClicked(player, _, id) - local index = tonumber(id) + local index = tonumber(id) or "" if index == 19 then setVisibility("toggle", player.color) @@ -296,8 +296,8 @@ function loadCameraFromApi(params) end -- loads the specified camera for a player ----@param player TTSPlayerInstance Player whose camera should be moved ----@param camera Variant If number: Index of the camera view to load | If string: Color of the playermat to swap to +---@param player tts__Player Player whose camera should be moved +---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to function loadCamera(player, camera) local lookHere, index, matColor local matColorList = { "White", "Orange", "Green", "Red" } diff --git a/src/core/OptionPanelApi.ttslua b/src/core/OptionPanelApi.ttslua index df678dff..acca1fb4 100644 --- a/src/core/OptionPanelApi.ttslua +++ b/src/core/OptionPanelApi.ttslua @@ -2,12 +2,12 @@ do local OptionPanelApi = {} -- loads saved options - ---@param options Table New options table + ---@param options table Set a new state for the option table OptionPanelApi.loadSettings = function(options) return Global.call("loadSettings", options) end - -- returns option panel table + ---@return any: Table of option panel state OptionPanelApi.getOptions = function() return Global.getTable("optionPanel") end diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index 76ce5567..d2342862 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -72,7 +72,7 @@ end -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the -- data to the local token manager instance. ----@param args Table Single-value array holding the GUID of the Custom Data Helper making the call +---@param args table Single-value array holding the GUID of the Custom Data Helper making the call function updateLocations(args) customDataHelper = getObjectFromGUID(args[1]) if customDataHelper ~= nil then @@ -125,7 +125,7 @@ function onCollisionEnter(collisionInfo) -- If this card was being dragged, clear the dragging connections. A multi-drag/drop may send -- the dropped card immediately into a deck, so this has to be done here if draggingGuids[object.getGUID()] ~= nil then - object.setVectorLines(nil) + object.setVectorLines({}) draggingGuids[object.getGUID()] = nil end @@ -197,7 +197,7 @@ function onUpdate() -- If object still exists then it's been dragged outside the area and needs to clear the -- lines attached to it if obj ~= nil then - obj.setVectorLines(nil) + obj.setVectorLines({}) end end -- Even if the last location left the play area, need one last draw to clear the lines @@ -213,7 +213,7 @@ end -- Checks the given card and adds it to the list of locations tracked for connection purposes. -- A card will be added to the tracking if it is a location in the play area (based on centerpoint). ----@param card Object A card object, possibly a location. +---@param card tts__Object A card object, possibly a location. function maybeTrackLocation(card) -- Collision checks for any part of the card overlap, but our other tracking is centerpoint -- Ignore any collision where the centerpoint isn't in the area @@ -243,7 +243,7 @@ end -- and destruction, as a destroyed object does not trigger collision exit. An object can also be -- deleted mid-drag, but the ordering for drag events means we can't clear those here and those will -- be cleared in the next onUpdate() cycle. ----@param card Object Card to (maybe) stop tracking +---@param card tts__Object Card to (maybe) stop tracking function maybeUntrackLocation(card) -- Locked objects no longer collide (hence triggering an exit event) but are still in the play -- area. If the object is now locked, don't remove it. @@ -257,11 +257,11 @@ end -- Global event handler, delegated from Global. Clears any connection lines from dragged cards -- before they are destroyed by entering a deck. Removal of the card from the dragging list will -- be handled during the next onUpdate() call. -function tryObjectEnterContainer(params) +function tryObjectEnterContainer() for draggedGuid, _ in pairs(draggingGuids) do local draggedObj = getObjectFromGUID(draggedGuid) if draggedObj ~= nil then - draggedObj.setVectorLines(nil) + draggedObj.setVectorLines({}) end end end @@ -299,9 +299,9 @@ function rebuildConnectionList() end -- Extracts the card's icon string into a list of individual location icons ----@param cardId String GUID of the card to pull the icon data from ----@param iconCardList Table A table of icon->GUID list. Mutable, will be updated by this method ----@param locData Table A table containing the metadata for the card (for the correct side) +---@param cardId string GUID of the card to pull the icon data from +---@param iconCardList table A table of icon->GUID list. Mutable, will be updated by this method +---@param locData table A table containing the metadata for the card (for the correct side) function buildLocListByIcon(cardId, iconCardList, locData) if locData ~= nil and locData.icons ~= nil then for icon in string.gmatch(locData.icons, "%a+") do @@ -315,9 +315,9 @@ end -- Builds the connections for the given cardID by finding matching icons and adding them to the -- Playarea's locationConnections table. ----@param cardId String GUID of the card to build the connections for ----@param iconCardList Table A table of icon->GUID List. Used to find matching icons for connections. ----@param locData Table A table containing the metadata for the card (for the correct side) +---@param cardId string GUID of the card to build the connections for +---@param iconCardList table A table of icon->GUID List. Used to find matching icons for connections. +---@param locData table A table containing the metadata for the card (for the correct side) function buildConnection(cardId, iconCardList, locData) if locData ~= nil and locData.connections ~= nil then locationConnections[cardId] = {} @@ -412,11 +412,11 @@ end -- Draws a bidirectional location connection between the two cards, adding the lines to do so to the -- given lines list. ----@param card1 Object One of the card objects to connect ----@param card2 Object The other card object to connect ----@param vectorOwner Object The object which these lines will be set to. Used for relative +---@param card1 tts__Object One of the card objects to connect +---@param card2 tts__Object The other card object to connect +---@param vectorOwner tts__Object The object which these lines will be set to. Used for relative --- positioning and scaling, as well as highlighting connections during a drag operation ----@param lines Table List of vector line elements. Mutable, will be updated to add this connector +---@param lines table List of vector line elements. Mutable, will be updated to add this connector function addBidirectionalVector(card1, card2, vectorOwner, lines) local cardPos1 = card1.getPosition() local cardPos2 = card2.getPosition() @@ -435,11 +435,11 @@ end -- Draws a one-way location connection between the two cards, adding the lines to do so to the -- given lines list. Arrows will point towards the target card. ----@param origin Object Origin card in the connection ----@param target Object Target card object to connect ----@param vectorOwner Object The object which these lines will be set to. Used for relative +---@param origin tts__Object Origin card in the connection +---@param target tts__Object Target card object to connect +---@param vectorOwner tts__Object The object which these lines will be set to. Used for relative --- positioning and scaling, as well as highlighting connections during a drag operation ----@param lines Table List of vector line elements. Mutable, will be updated to add this connector +---@param lines table List of vector line elements. Mutable, will be updated to add this connector function addOneWayVector(origin, target, vectorOwner, lines) -- Start with the BiDi then add the arrow lines to it addBidirectionalVector(origin, target, vectorOwner, lines) @@ -451,13 +451,11 @@ function addOneWayVector(origin, target, vectorOwner, lines) -- Calculate card distance to be closer for horizontal positions than vertical, since cards are -- taller than they are wide local heading = Vector(originPos):sub(targetPos):heading("y") - local distanceFromCard = DIRECTIONAL_ARROW_DISTANCE * 0.7 + - DIRECTIONAL_ARROW_DISTANCE * 0.3 * math.abs(math.sin(math.rad(heading))) + local distanceFromCard = DIRECTIONAL_ARROW_DISTANCE * 0.7 + DIRECTIONAL_ARROW_DISTANCE * 0.3 * math.abs(math.sin(math.rad(heading))) -- Calculate the three possible arrow positions. These are offset by half the arrow length to -- make them visually balanced by keeping the arrows centered, not tracking the point - local midpoint = Vector(originPos):add(targetPos):scale(Vector(0.5, 0.5, 0.5)):moveTowards(targetPos, - ARROW_ARM_LENGTH / 2) + local midpoint = Vector(originPos):add(targetPos):scale(0.5):moveTowards(targetPos, ARROW_ARM_LENGTH / 2) local closeToOrigin = Vector(originPos):moveTowards(targetPos, distanceFromCard + ARROW_ARM_LENGTH / 2) local closeToTarget = Vector(targetPos):moveTowards(originPos, distanceFromCard - ARROW_ARM_LENGTH / 2) @@ -470,16 +468,14 @@ function addOneWayVector(origin, target, vectorOwner, lines) end -- Draws an arrowhead at the given position. ----@param arrowheadPos Table Centerpoint of the arrowhead to draw (NOT the tip of the arrow) ----@param originPos Table Origin point of the connection, used to position the arrow arms ----@param vectorOwner Object The object which these lines will be set to. Used for relative +---@param arrowheadPos tts__Vector Centerpoint of the arrowhead to draw (NOT the tip of the arrow) +---@param originPos tts__Vector Origin point of the connection, used to position the arrow arms +---@param vectorOwner tts__Object The object which these lines will be set to. Used for relative --- positioning and scaling, as well as highlighting connections during a drag operation ----@param lines Table List of vector line elements. Mutable, will be updated to add this arrow +---@param lines table List of vector line elements. Mutable, will be updated to add this arrow function addArrowLines(arrowheadPos, originPos, vectorOwner, lines) - local arrowArm1 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver("y", - -1 * ARROW_ANGLE):add(arrowheadPos) - local arrowArm2 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver("y", - ARROW_ANGLE):add(arrowheadPos) + local arrowArm1 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver("y", -1 * ARROW_ANGLE):add(arrowheadPos) + local arrowArm2 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver("y", ARROW_ANGLE):add(arrowheadPos) local head = vectorOwner.positionToLocal(arrowheadPos) local arm1 = vectorOwner.positionToLocal(arrowArm1) @@ -493,7 +489,7 @@ end -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded' ----@param playerColor String Color of the player requesting the shift. Used solely to send an error +---@param playerColor string Color of the player requesting the shift. Used solely to send an error --- message in the unlikely case that the scripting zone has been deleted function shiftContentsUp(playerColor) shiftContents(playerColor, "up") @@ -528,8 +524,8 @@ end -- Check to see if the given object is within the bounds of the play area, based solely on the X and -- Z coordinates, ignoring height ----@param object Object Object to check ----@return. True if the object is inside the play area +---@param object tts__Object Object to check +---@return boolean: True if the object is inside the play area function isInPlayArea(object) local bounds = self.getBounds() local position = object.getPosition() @@ -553,7 +549,7 @@ end -- Sets this playmat's snap points to limit snapping to locations or not. -- If matchTypes is false, snap points will be reset to snap all cards. ----@param matchTypes Boolean Whether snap points should only snap for the matching card types. +---@param matchTypes boolean Whether snap points should only snap for the matching card types. function setLimitSnapsByType(matchTypes) local snaps = self.getSnapPoints() for i, snap in ipairs(snaps) do @@ -586,7 +582,7 @@ function setConnectionColor(color) end -- count victory points on locations in play area ----@param highlightOff Boolean True if highlighting should be enabled +---@param highlightOff boolean True if highlighting should be enabled ---@return. Returns the total amount of VP found in the play area function countVP(highlightOff) local totalVP = 0 @@ -612,14 +608,14 @@ function countVP(highlightOff) end -- checks if a card has clues on it, returns true if clues are on it ----@param card TTSObject Card to check for clues +---@param card tts__Object Card to check for clues function cardHasClues(card) local searchResult = searchLib.onObject(card, "isClue") return #searchResult > 0 end -- highlights all locations in the play area without metadata ----@param state Boolean True if highlighting should be enabled +---@param state boolean True if highlighting should be enabled function highlightMissingData(state) for i, obj in pairs(missingData) do if obj ~= nil then diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua index e88b84a1..37792dba 100644 --- a/src/core/PlayAreaApi.ttslua +++ b/src/core/PlayAreaApi.ttslua @@ -11,55 +11,55 @@ do end -- Returns the current value of the investigator counter from the playmat - ---@return Integer. Number of investigators currently set on the counter + ---@return number: Number of investigators currently set on the counter PlayAreaApi.getInvestigatorCount = function() return getInvestigatorCounter().getVar("val") end -- Updates the current value of the investigator counter from the playmat - ---@param count Number of investigators to set on the counter + ---@param count number Number of investigators to set on the counter PlayAreaApi.setInvestigatorCount = function(count) getInvestigatorCounter().call("updateVal", count) end - -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain + -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded' - ---@param playerColor Color Color of the player requesting the shift for messages + ---@param playerColor string Color of the player requesting the shift for messages PlayAreaApi.shiftContentsUp = function(playerColor) - return getPlayArea().call("shiftContentsUp", playerColor) + getPlayArea().call("shiftContentsUp", playerColor) end PlayAreaApi.shiftContentsDown = function(playerColor) - return getPlayArea().call("shiftContentsDown", playerColor) + getPlayArea().call("shiftContentsDown", playerColor) end PlayAreaApi.shiftContentsLeft = function(playerColor) - return getPlayArea().call("shiftContentsLeft", playerColor) + getPlayArea().call("shiftContentsLeft", playerColor) end PlayAreaApi.shiftContentsRight = function(playerColor) - return getPlayArea().call("shiftContentsRight", playerColor) + getPlayArea().call("shiftContentsRight", playerColor) end - -- Sets whether location connections should be drawn + ---@param state boolean This controls whether location connections should be drawn PlayAreaApi.setConnectionDrawState = function(state) getPlayArea().call("setConnectionDrawState", state) end - -- Sets the connection color + ---@param color string Connection color to be used for location connections PlayAreaApi.setConnectionColor = function(color) getPlayArea().call("setConnectionColor", color) end - -- Event to be called when the current scenario has changed. - ---@param scenarioName Name of the new scenario + -- Event to be called when the current scenario has changed + ---@param scenarioName string Name of the new scenario PlayAreaApi.onScenarioChanged = function(scenarioName) getPlayArea().call("onScenarioChanged", scenarioName) end -- Sets this playmat's snap points to limit snapping to locations or not. -- If matchTypes is false, snap points will be reset to snap all cards. - ---@param matchCardTypes Boolean Whether snap points should only snap for the matching card types. + ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types PlayAreaApi.setLimitSnapsByType = function(matchCardTypes) getPlayArea().call("setLimitSnapsByType", matchCardTypes) end @@ -76,13 +76,13 @@ do end -- highlights all locations in the play area without metadata - ---@param state Boolean True if highlighting should be enabled + ---@param state boolean True if highlighting should be enabled PlayAreaApi.highlightMissingData = function(state) return getPlayArea().call("highlightMissingData", state) end -- highlights all locations in the play area with VP - ---@param state Boolean True if highlighting should be enabled + ---@param state boolean True if highlighting should be enabled PlayAreaApi.highlightCountedVP = function(state) return getPlayArea().call("countVP", state) end @@ -102,7 +102,7 @@ do -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the -- data to the local token manager instance. - ---@param args Table Single-value array holding the GUID of the Custom Data Helper making the call + ---@param args table Single-value array holding the GUID of the Custom Data Helper making the call PlayAreaApi.updateLocations = function(args) getPlayArea().call("updateLocations", args) end diff --git a/src/core/PlayAreaSelector.ttslua b/src/core/PlayAreaSelector.ttslua index 24a802e8..b6ba26be 100644 --- a/src/core/PlayAreaSelector.ttslua +++ b/src/core/PlayAreaSelector.ttslua @@ -131,8 +131,8 @@ function highlightTabAndItem() end -- loops through an XML table and returns the specified object ----@param ui Table XmlTable (get this via getXmlTable) ----@param id String Id of the object to return +---@param ui table XmlTable (get this via getXmlTable) +---@param id string Id of the object to return function getXmlTableElementById(ui, id) for _, obj in ipairs(ui) do if obj.attributes and obj.attributes.id and obj.attributes.id == id then return obj end diff --git a/src/core/SoundCubeApi.ttslua b/src/core/SoundCubeApi.ttslua index 8aec117b..e078b7d3 100644 --- a/src/core/SoundCubeApi.ttslua +++ b/src/core/SoundCubeApi.ttslua @@ -9,13 +9,14 @@ do ["Dark Souls"] = 2 } + ---@param index number Index of the sound effect to play local function playTriggerEffect(index) local SoundCube = guidReferenceApi.getObjectByOwnerAndType("Mythos", "SoundCube") SoundCube.AssetBundle.playTriggerEffect(index) end -- plays the by name requested sound - ---@param soundName String Name of the sound to play + ---@param soundName string Name of the sound to play SoundCubeApi.playSoundByName = function(soundName) playTriggerEffect(soundIndices[soundName]) end diff --git a/src/core/VictoryDisplayApi.ttslua b/src/core/VictoryDisplayApi.ttslua index ae057130..64c744d2 100644 --- a/src/core/VictoryDisplayApi.ttslua +++ b/src/core/VictoryDisplayApi.ttslua @@ -6,14 +6,14 @@ do return guidReferenceApi.getObjectByOwnerAndType("Mythos", "VictoryDisplay") end - -- triggers an update of the Victory count - ---@param delay Number Delay in seconds after which the update call is executed + -- triggers an update of the victory count + ---@param delay number Delay in seconds after which the update call is executed VictoryDisplayApi.update = function(delay) getVictoryDisplay().call("startUpdate", delay) end -- moves a card to the victory display (in the first empty spot) - ---@param object Object Object that should be checked and potentially moved + ---@param object tts__Object Object that should be checked and potentially moved VictoryDisplayApi.placeCard = function(object) if object ~= nil and object.tag == "Card" then getVictoryDisplay().call("placeCard", object) diff --git a/src/core/token/TokenManager.ttslua b/src/core/token/TokenManager.ttslua index b216a8bd..06ffd0ac 100644 --- a/src/core/token/TokenManager.ttslua +++ b/src/core/token/TokenManager.ttslua @@ -135,8 +135,8 @@ do -- the work once a card has hit an area where it might spawn tokens. It will check to see if -- the card has already spawned, find appropriate data from either the uses metadata or the Data -- Helper, and spawn the tokens. - ---@param card Object Card to maybe spawn tokens for - ---@param extraUses Table A table of = which will modify the number of tokens + ---@param card tts__Object Card to maybe spawn tokens for + ---@param extraUses table A table of = which will modify the number of tokens --- spawned for that type. e.g. Akachi's playmat should pass "Charge"=1 TokenManager.spawnForCard = function(card, extraUses) if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then @@ -151,13 +151,12 @@ do end -- Spawns a set of tokens on the given card. - ---@param card Object Card to spawn tokens on - ---@param tokenType String Type of token to spawn, valid values are "damage", "horror", - -- "resource", "doom", or "clue" - ---@param tokenCount Number How many tokens to spawn. For damage or horror this value will be set to the + ---@param card tts__Object Card to spawn tokens on + ---@param tokenType string Type of token to spawn, for example "damage", "horror" or "resource" + ---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the -- spawned state object rather than spawning multiple tokens - ---@param shiftDown Number An offset for the z-value of this group of tokens - ---@param subType String Subtype of token to spawn. This will only differ from the tokenName for resource tokens + ---@param shiftDown? number An offset for the z-value of this group of tokens + ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType) local optionPanel = optionPanelApi.getOptions() @@ -174,10 +173,10 @@ do -- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror -- tokens. - ---@param card Object Card to spawn tokens on - ---@param tokenType String type of token to spawn, valid values are "damage" and "horror". Other + ---@param card tts__Object Card to spawn tokens on + ---@param tokenType string type of token to spawn, valid values are "damage" and "horror". Other -- types should use spawnMultipleTokens() - ---@param tokenValue Number Value to set the damage/horror to + ---@param tokenValue number Value to set the damage/horror to TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown) if tokenValue < 1 or tokenValue > 50 then return end @@ -195,11 +194,11 @@ do end -- Spawns a number of tokens. - ---@param tokenType String type of token to spawn, valid values are resource", "doom", or "clue". + ---@param tokenType string type of token to spawn, valid values are resource", "doom", or "clue". -- Other types should use spawnCounterToken() - ---@param tokenCount Number How many tokens to spawn - ---@param shiftDown Number An offset for the z-value of this group of tokens - ---@param subType String Subtype of token to spawn. This will only differ from the tokenName for resource tokens + ---@param tokenCount number How many tokens to spawn + ---@param shiftDown? number An offset for the z-value of this group of tokens + ---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType) -- not checking the max at this point since clue offsets are calculated dynamically if tokenCount < 1 then return end @@ -253,12 +252,12 @@ do end -- Spawns a single token at the given global position by copying it from the template bag. - ---@param position Global position to spawn the token - ---@param tokenType String type of token to spawn, valid values are "damage", "horror", + ---@param position tts__Vector Global position to spawn the token + ---@param tokenType string type of token to spawn, valid values are "damage", "horror", -- "resource", "doom", or "clue" - ---@param rotation Vector Rotation to be used for the new token. Only the y-value will be used, + ---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used, -- x and z will use the default rotation from the source bag - ---@param callback function A callback function triggered after the new token is spawned + ---@param callback? function A callback function triggered after the new token is spawned TokenManager.spawnToken = function(position, tokenType, rotation, callback) internal.initTokenTemplates() local loadTokenType = tokenType @@ -292,9 +291,9 @@ do end -- Checks a card for metadata to maybe replenish it - ---@param card Object Card object to be replenished - ---@param uses Table The already decoded metadata.uses (to avoid decoding again) - ---@param mat Object The playmat the card is placed on (for rotation and casting) + ---@param card tts__Object Card object to be replenished + ---@param uses table The already decoded metadata.uses (to avoid decoding again) + ---@param mat tts__Object The playmat the card is placed on (for rotation and casting) TokenManager.maybeReplenishCard = function(card, uses, mat) -- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that) if uses[1].count and uses[1].replenish then @@ -304,13 +303,13 @@ do -- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some -- callers. - ---@param card Object Card object to reset the tokens for + ---@param card tts__Object Card object to reset the tokens for TokenManager.resetTokensSpawned = function(card) tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID()) end -- Pushes new player card data into the local copy of the Data Helper player data. - ---@param dataTable Table Key/Value pairs following the DataHelper style + ---@param dataTable table Key/Value pairs following the DataHelper style TokenManager.addPlayerCardData = function(dataTable) internal.initDataHelperData() for k, v in pairs(dataTable) do @@ -319,7 +318,7 @@ do end -- Pushes new location data into the local copy of the Data Helper location data. - ---@param dataTable Table Key/Value pairs following the DataHelper style + ---@param dataTable table Key/Value pairs following the DataHelper style TokenManager.addLocationData = function(dataTable) internal.initDataHelperData() for k, v in pairs(dataTable) do @@ -328,8 +327,8 @@ do end -- Checks to see if the given card has location data in the DataHelper - ---@param card Object Card to check for data - ---@return Boolean True if this card has data in the helper, false otherwise + ---@param card tts__Object Card to check for data + ---@return boolean: True if this card has data in the helper, false otherwise TokenManager.hasLocationData = function(card) internal.initDataHelperData() return internal.getLocationData(card) ~= nil @@ -359,8 +358,8 @@ do -- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state -- of the card for both locations and standard cards. - ---@param card Object Card to maybe spawn tokens for - ---@param extraUses Table A table of = which will modify the number of tokens + ---@param card tts__Object Card to maybe spawn tokens for + ---@param extraUses table A table of = which will modify the number of tokens --- spawned for that type. e.g. Akachi's playmat should pass "Charge"=1 internal.spawnTokensFromUses = function(card, extraUses) local uses = internal.getUses(card) @@ -382,7 +381,7 @@ do -- Spawn tokens for a card based on the data helper data. This will consider the face up/down state -- of the card for both locations and standard cards. - ---@param card Object Card to maybe spawn tokens for + ---@param card tts__Object Card to maybe spawn tokens for internal.spawnTokensFromDataHelper = function(card) internal.initDataHelperData() local playerData = internal.getPlayerCardData(card) @@ -396,8 +395,8 @@ do end -- Spawn tokens for a player card using data retrieved from the Data Helper. - ---@param card Object Card to maybe spawn tokens for - ---@param playerData Table Player card data structure retrieved from the DataHelper. Should be + ---@param card tts__Object Card to maybe spawn tokens for + ---@param playerData table Player card data structure retrieved from the DataHelper. Should be -- the right data for this card. internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData) local token = playerData.tokenType @@ -407,8 +406,8 @@ do end -- Spawn tokens for a location using data retrieved from the Data Helper. - ---@param card Object Card to maybe spawn tokens for - ---@param locationData Table Location data structure retrieved from the DataHelper. Should be + ---@param card tts__Object Card to maybe spawn tokens for + ---@param locationData table Location data structure retrieved from the DataHelper. Should be -- the right data for this card. internal.spawnLocationTokensFromDataHelper = function(card, locationData) local clueCount = internal.getClueCountFromData(card, locationData) @@ -447,7 +446,7 @@ do end -- Gets the right uses structure for this card, based on metadata and face up/down state - ---@param card Object Card to pull the uses from + ---@param card tts__Object Card to pull the uses from internal.getUses = function(card) local metadata = JSON.decode(card.getGMNotes()) or { } if metadata.type == "Location" then @@ -464,9 +463,9 @@ do end -- Dynamically create positions for clues on a card. - ---@param card Object Card the clues will be placed on - ---@param count Integer How many clues? - ---@return Table Array of global positions to spawn the clues at + ---@param card tts__Object Card the clues will be placed on + ---@param count number How many clues? + ---@return table: Array of global positions to spawn the clues at internal.buildClueOffsets = function(card, count) local pos = card.getPosition() local cluePositions = { } @@ -478,9 +477,9 @@ do return cluePositions end - ---@param card Object Card object to be replenished - ---@param uses Table The already decoded metadata.uses (to avoid decoding again) - ---@param mat Object The playmat the card is placed on (for rotation and casting) + ---@param card tts__Object Card object to be replenished + ---@param uses table The already decoded metadata.uses (to avoid decoding again) + ---@param mat tts__Object The playmat the card is placed on (for rotation and casting) internal.replenishTokens = function(card, uses, mat) local cardPos = card.getPosition() diff --git a/src/core/tour/TourManager.ttslua b/src/core/tour/TourManager.ttslua index f2150e4d..3e7d0d1d 100644 --- a/src/core/tour/TourManager.ttslua +++ b/src/core/tour/TourManager.ttslua @@ -56,7 +56,7 @@ do -- Kicks off the tour by initializing the card and camera hook. A callback on the hook creation -- will then show the first card. - ---@param playerColor String Player color to start the tour for + ---@param playerColor string Player color to start the tour for TourManager.startTour = function(playerColor) tourState[playerColor] = { currentCardIndex = 1 @@ -83,7 +83,7 @@ do -- Shows the next card in the tour script. This method is exposed (rather than being part of -- internal) because the XMLUI callbacks expect the method to be on the object directly. - ---@param player Player object to show the next card for, provided by XMLUI callback + ---@param player tts__Player object to show the next card for, provided by XMLUI callback function nextCard(player) internal.hideCard(player.color) Wait.time(function() @@ -98,7 +98,7 @@ do -- Ends the tour and cleans up the camera. This method is exposed (rather than being part of -- internal) because the XMLUI callbacks expect the method to be on the object directly. - ---@param player Player object to end the tour for, provided by XMLUI callback + ---@param player tts__Player object to end the tour for, provided by XMLUI callback function stopTour(player) internal.hideCard(player.color) Wait.time(function() @@ -108,7 +108,7 @@ do -- Updates the card UI for the script at the current index, moves the camera to the proper -- position, and shows the card. - ---@param playerColor String Player color to show the current card for + ---@param playerColor string Player color to show the current card for internal.showCurrentCard = function(playerColor) internal.updateCardDisplay(playerColor) local delay = 0 @@ -143,7 +143,7 @@ do -- Hides the current card being shown to a player. This can be in preparation for showing the -- next card, or ending the tour. - ---@param playerColor String Player color to hide the current card for + ---@param playerColor string Player color to hide the current card for internal.hideCard = function(playerColor) Global.UI.hide(internal.getUiId(CARD_ID, playerColor)) end @@ -151,7 +151,7 @@ do -- Cleans up all the various resources associated with the tour, and (hopefully) resets the -- camera to the default position. Camera handling is erratic, the final card in the script -- should include instructions for the player to fix it. - ---@param playerColor String Player color to clean up + ---@param playerColor string Player color to clean up internal.finalizeTour = function(playerColor) local cameraHook = getObjectFromGUID(tourState[playerColor].cameraHookGuid) cameraHook.destruct() @@ -163,7 +163,7 @@ do end -- Updates the card UI to show the appropriate card configuration. - ---@param playerColor String Player color to update card for + ---@param playerColor string Player color to update card for internal.updateCardDisplay = function(playerColor) local index = tourState[playerColor].currentCardIndex Global.UI.setAttribute(internal.getUiId(LEFT_NARRATOR_ID, playerColor), "image", "Inv-" .. TOUR_SCRIPT[index].narrator) @@ -195,7 +195,7 @@ do -- user's view around the table. This should be called only at the beginning of the tour. Once -- creation is complete the user's camera will be attached to the hook and the first card will be -- shown. - ---@param playerColor String Player color to create the hook for + ---@param playerColor string Player color to create the hook for internal.createCameraHook = function(playerColor) local hookData = { Name = "BlockSquare", @@ -225,7 +225,7 @@ do -- Callback for creation of the camera hook object. Will attach the camera and show the current -- (presumably first) card. - ---@param hook Created object + ---@param hook tts__Object Created object internal.onHookCreated = function(hook) local playerColor = hook.getGMNotes() tourState[playerColor].cameraHookGuid = hook.getGUID() @@ -238,7 +238,7 @@ do -- Creates an XMLUI entry in Global for a player-specific tour card. Dynamically creating this -- is somewhat complex, but ensures we can properly handle any player color. - ---@param playerColor String Player color to create the card for + ---@param playerColor string Player color to create the card for internal.createTourCard = function(playerColor) -- Make sure the card doesn't exist before we create a new one if Global.UI.getAttributes(internal.getUiId(CARD_ID, playerColor)) ~= nil then return end @@ -261,8 +261,8 @@ do -- Panels don't cause their children to inherit their visibility value, so this recurses down the -- XML table to set all children to the same visibility. - ---@param xmlUi Table. Lua table describing the XML - ---@param playerColor String. String color of the player to make this visible for + ---@param xmlUi table Lua table describing the XML + ---@param playerColor string String color of the player to make this visible for internal.setDeepVisibility = function(xmlUi, playerColor) xmlUi.attributes.visibility = "" .. playerColor if xmlUi.children ~= nil then diff --git a/src/playercards/AllCardsBag.ttslua b/src/playercards/AllCardsBag.ttslua index 7b70b556..33d6515d 100644 --- a/src/playercards/AllCardsBag.ttslua +++ b/src/playercards/AllCardsBag.ttslua @@ -5,7 +5,6 @@ local uniqueWeaknessList = { } local cycleIndex = { } local indexingDone = false -local allowRemoval = false function onLoad() self.addContextMenuItem("Rebuild Index", startIndexBuild) @@ -47,25 +46,17 @@ function clearIndexes() end -- Clears the bag indexes and starts the coroutine to rebuild the indexes -function startIndexBuild(playerColor) +function startIndexBuild() clearIndexes() startLuaCoroutine(self, "buildIndex") end -function onObjectLeaveContainer(container, object) - if (container == self and not allowRemoval) then - broadcastToAll( - "Removing cards from the All Player Cards bag may break some functions. Please replace the card.", - {0.9, 0.2, 0.2} - ) +function onObjectLeaveContainer(container, _) + if container == self then + broadcastToAll("Removing cards from the All Player Cards bag may break some functions.", "Red") end end --- Debug option to suppress the warning when cards are removed from the bag -function setAllowCardRemoval() - allowRemoval = true -end - -- Create the card indexes by iterating all cards in the bag, parsing their -- metadata, and creating the keyed lookup tables for the cards. This is a -- coroutine which will spread the workload by processing 20 cards before @@ -124,8 +115,8 @@ function buildIndex() end -- Adds a card to any indexes it should be a part of, based on its metadata. ----@param cardData: TTS object data for the card ----@param cardMetadata: SCED metadata for the card +---@param cardData table TTS object data for the card +---@param cardMetadata table SCED metadata for the card function addCardToIndex(cardData, cardMetadata) -- use the ZoopGuid as fallback if no id present if cardMetadata.id == nil and cardMetadata.TtsZoopGuid then diff --git a/src/playercards/AllCardsBagApi.ttslua b/src/playercards/AllCardsBagApi.ttslua index 83cf6463..350f2f8d 100644 --- a/src/playercards/AllCardsBagApi.ttslua +++ b/src/playercards/AllCardsBagApi.ttslua @@ -21,7 +21,7 @@ do -- it will be removed from the list and cannot be selected again until a reload -- occurs or the indexes are rebuilt, which will refresh the list to include all -- weaknesses. - ---@return id String ID of the selected weakness. + ---@return string: ID of the selected weakness. AllCardsBagApi.getRandomWeaknessId = function() return getAllCardsBag().call("getRandomWeaknessId") end @@ -41,8 +41,8 @@ do -- Searches the bag for cards which match the given name and returns a list. Note that this is -- an O(n) search without index support. It may be slow. - ---@param name String or string fragment to search for names - ---@param exact Boolean Whether the name match should be exact + ---@param name string or string fragment to search for names + ---@param exact boolean Whether the name match should be exact AllCardsBagApi.getCardsByName = function(name, exact) return getAllCardsBag().call("getCardsByName", {name = name, exact = exact}) end @@ -52,9 +52,9 @@ do end -- Returns a list of cards from the bag matching a class and level (0 or upgraded) - ---@param class String class to retrieve ("Guardian", "Seeker", etc) - ---@param upgraded Boolean true for upgraded cards (Level 1-5), false for Level 0 - ---@return: If the indexes are still being constructed, returns an empty table. + ---@param class string class to retrieve ("Guardian", "Seeker", etc) + ---@param upgraded boolean true for upgraded cards (Level 1-5), false for Level 0 + ---@return table: If the indexes are still being constructed, returns an empty table. -- Otherwise, a list of tables, each with the following fields -- cardData: TTS object data, suitable for spawning the card -- cardMetadata: Table of parsed metadata diff --git a/src/playercards/PlayerCardPanel.ttslua b/src/playercards/PlayerCardPanel.ttslua index 0b4e2c96..6f3e5eeb 100644 --- a/src/playercards/PlayerCardPanel.ttslua +++ b/src/playercards/PlayerCardPanel.ttslua @@ -1,3 +1,4 @@ +---@diagnostic disable: param-type-mismatch require("playercards/PlayerCardPanelData") local allCardsBagApi = require("playercards/AllCardsBagApi") @@ -386,8 +387,7 @@ function updateStarterModeButtons() createInvestigatorModeButtons() end --- Clears the table and updates positions based on scale. Should be called before ANY card --- placement +-- Clears the table and updates positions based on scale (should be called before ANY card placement) function prepareToPlaceCards() deleteAll() scalePositions() @@ -401,8 +401,7 @@ function scalePositions() startPositions = { } for key, pos in pairs(START_POSITIONS) do -- Because a scaled object means a different global size, using global distance for Z results in - -- the cards being closer or farther depending on the scale. Leave the Z values and only scale - -- X and Y + -- the cards being closer or farther depending on the scale. Leave the Z values and only scale X and Y startPositions[key] = Vector(pos) startPositions[key].x = startPositions[key].x * scale startPositions[key].y = startPositions[key].y * scale @@ -422,7 +421,7 @@ end -- Spawn an investigator group, based on the current UI setting for either investigators or starter -- decks. ----@param groupName String. Name of the group to spawn, matching a key in InvestigatorPanelData +---@param groupName string Name of the group to spawn, matching a key in InvestigatorPanelData function spawnInvestigatorGroup(groupName) local starterMode = starterDeckMode == STARTER_DECK_MODE_STARTERS prepareToPlaceCards() @@ -437,7 +436,7 @@ end -- Spawn cards for all investigators in the given group. This creates piles for all defined -- investigator cards and minicards as well as the signature cards. ----@param groupName String. Name of the group to spawn, matching a key in InvestigatorPanelData +---@param groupName string Name of the group to spawn, matching a key in InvestigatorPanelData function spawnInvestigators(groupName) if INVESTIGATOR_GROUPS[groupName] == nil then printToAll("No " .. groupName .. " data yet") @@ -480,20 +479,18 @@ function getInvestigatorRowStartPos(investigatorCount, row) end -- Creates the spawn spec for the investigator's signature cards. ----@param investigatorName String. Name of the investigator, matching a key in ---- InvestigatorPanelData ----@param investigatorData Table. Spawn definition for the investigator, retrieved from ---- INVESTIGATORS ----@param position Vector. Where to spawn the minicard; investigagor cards will be placed below +---@param investigatorName string Name of the investigator, matching a key in InvestigatorPanelData +---@param investigatorData table Spawn definition for the investigator, retrieved from INVESTIGATORS +---@param position tts__Vector Where to spawn the minicard; investigagor cards will be placed below function buildInvestigatorSpawnSpec(investigatorName, investigatorData, position) local sigPos = Vector(position):add(investigatorSignatureOffset) local spawns = buildCommonSpawnSpec(investigatorName, investigatorData, position) table.insert(spawns, { - name = investigatorName.."signatures", - cards = investigatorData.signatures, - globalPos = self.positionToWorld(sigPos), - rotation = FACE_UP_ROTATION, - }) + name = investigatorName.."signatures", + cards = investigatorData.signatures, + globalPos = self.positionToWorld(sigPos), + rotation = FACE_UP_ROTATION, + }) return spawns end @@ -501,34 +498,32 @@ end -- Builds the spawn specs for minicards and investigator cards. These are common enough to be -- shared, and will only differ in whether they spawn the full stack of possible investigator and -- minicards, or only the first of each. ----@param investigatorName String. Name of the investigator, matching a key in ---- InvestigatorPanelData ----@param investigatorData Table. Spawn definition for the investigator, retrieved from ---- INVESTIGATORS ----@param position Vector. Where to spawn the minicard; investigagor cards will be placed below ----@param oneCardOnly Boolean. If true, will spawn only the first card in the investigator card +---@param investigatorName string Name of the investigator, matching a key in InvestigatorPanelData +---@param investigatorData table Spawn definition for the investigator, retrieved from INVESTIGATORS +---@param position tts__Vector Where to spawn the minicard; investigagor cards will be placed below +---@param oneCardOnly? boolean If true, will spawn only the first card in the investigator card --- and minicard lists. Otherwise, spawn them all in a deck function buildCommonSpawnSpec(investigatorName, investigatorData, position, oneCardOnly) local cardPos = Vector(position):add(investigatorCardOffset) return { - { - name = investigatorName.."minicards", - cards = oneCardOnly and { investigatorData.minicards[1] } or investigatorData.minicards, - globalPos = self.positionToWorld(position), - rotation = FACE_UP_ROTATION, - }, - { - name = investigatorName.."cards", - cards = oneCardOnly and { investigatorData.cards[1] } or investigatorData.cards, - globalPos = self.positionToWorld(cardPos), - rotation = FACE_UP_ROTATION, - }, + { + name = investigatorName.."minicards", + cards = oneCardOnly and { investigatorData.minicards[1] } or investigatorData.minicards, + globalPos = self.positionToWorld(position), + rotation = FACE_UP_ROTATION, + }, + { + name = investigatorName.."cards", + cards = oneCardOnly and { investigatorData.cards[1] } or investigatorData.cards, + globalPos = self.positionToWorld(cardPos), + rotation = FACE_UP_ROTATION, + } } end -- Spawns all starter decks (single minicard and investigator card, plus the starter deck) for -- investigators in the given group. ----@param groupName String. Name of the group to spawn, matching a key in InvestigatorPanelData +---@param groupName string Name of the group to spawn, matching a key in InvestigatorPanelData function spawnStarters(groupName) local col = 1 local row = 1 @@ -547,8 +542,7 @@ function spawnStarters(groupName) end -- Spawns the defined starter deck for the given investigator's. ----@param investigatorName String. Name of the investigator, matching a key in ---- InvestigatorPanelData +---@param investigatorName string Name of the investigator, matching a key in InvestigatorPanelData function spawnStarterDeck(investigatorName, investigatorData, position) for _, spawnSpec in ipairs( buildCommonSpawnSpec(investigatorName, INVESTIGATORS[investigatorName], position, true)) do @@ -571,16 +565,16 @@ function spawnStarterDeck(investigatorName, investigatorData, position) end) end -- Clears the currently placed cards, then places cards for the given class and level spread ----@param cardClass String. Class to place ("Guardian", "Seeker", etc) ----@param isUpgraded Boolean. If true, spawn the Level 1-5 cards. Otherwise, Level 0. +---@param cardClass string Class to place ("Guardian", "Seeker", etc) +---@param isUpgraded boolean If true, spawn the Level 1-5 cards. Otherwise, Level 0. function spawnClassCards(cardClass, isUpgraded) prepareToPlaceCards() Wait.frames(function() placeClassCards(cardClass, isUpgraded) end, 2) end -- Spawn the class cards. ----@param cardClass String. Class to place ("Guardian", "Seeker", etc) ----@param isUpgraded Boolean. If true, spawn the Level 1-5 cards. Otherwise, Level 0. +---@param cardClass string Class to place ("Guardian", "Seeker", etc) +---@param isUpgraded boolean If true, spawn the Level 1-5 cards. Otherwise, Level 0. function placeClassCards(cardClass, isUpgraded) local indexReady = allCardsBagApi.isIndexReady() if (not indexReady) then @@ -638,7 +632,7 @@ function placeClassCards(cardClass, isUpgraded) end -- Spawns the investigator sets and all cards for the given cycle ----@param cycle String Name of a cycle, should match the standard used in card metadata +---@param cycle string Name of a cycle, should match the standard used in card metadata function spawnCycle(cycle) prepareToPlaceCards() spawnInvestigators(cycle) diff --git a/src/playercards/PlayerCardSpawner.ttslua b/src/playercards/PlayerCardSpawner.ttslua index d6c23ecf..cd14b1cb 100644 --- a/src/playercards/PlayerCardSpawner.ttslua +++ b/src/playercards/PlayerCardSpawner.ttslua @@ -77,7 +77,7 @@ end -- Spawn a specific list of cards. This method is for internal use and should not be called -- directly, use spawnCards instead. ----@param cardList: A list of Player Card data structures (data/metadata) +---@param cardList table A list of Player Card data structures (data/metadata) ---@param pos table Position where the cards should be spawned (global) ---@param rot table Rotation for the orientation of the spawned cards (global) ---@param callback function callback to be called after the card/deck spawns. @@ -130,8 +130,8 @@ end -- 3. Extract the card's CustomDeck table and add it to the deck. The deck's -- "CustomDeck" field is a list of all CustomDecks used by cards within the -- deck, keyed by the DeckID and referencing the custom deck table ----@param deck: TTS deck data structure to add to ----@param cardData: Data for the card to be inserted +---@param deck table TTS deck data structure to add to +---@param cardData table Data for the card to be inserted Spawner.addCardToDeck = function(deck, cardData) for customDeckId, customDeckData in pairs(cardData.CustomDeck) do if (deck.CustomDeck[customDeckId] == nil) then @@ -166,7 +166,7 @@ end -- Create an empty deck data table which can have cards added to it. This -- creates a new table on each call without using metatables or previous -- definitions because we can't be sure that TTS doesn't modify the structure ----@return: Table containing the minimal TTS deck data structure +---@return table deck Table containing the minimal TTS deck data structure Spawner.buildDeckDataTemplate = function() local deck = {} deck.Name = "Deck" @@ -200,7 +200,7 @@ Spawner.findNextAvailableId = function(objectTable, startId) end -- Get the PBCN (Permanent/Bonded/Customizable/Normal) value from the given metadata. ----@return: 1 for Permanent, 2 for Bonded or 4 for Normal. The actual values are +---@return number PBCN 1 for Permanent, 2 for Bonded or 4 for Normal. The actual values are -- irrelevant as they provide only grouping and the order between them doesn't matter. Spawner.getpbcn = function(metadata) if metadata.permanent then diff --git a/src/playercards/SpawnBag.ttslua b/src/playercards/SpawnBag.ttslua index 3db65eae..dce3e2ae 100644 --- a/src/playercards/SpawnBag.ttslua +++ b/src/playercards/SpawnBag.ttslua @@ -54,7 +54,7 @@ do Locked = true, Grid = true, Snap = false, - Tooltip = false, + Tooltip = false } -- Tracks what has been placed by this "bag" so they can be recalled @@ -113,7 +113,7 @@ do end -- Recalls all spawned objects to the bag, and clears the placedObjectGuids list - ---@param fast Boolean. If true, cards will be deleted directly without faking the bag recall. + ---@param fast boolean If true, cards will be deleted directly without faking the bag recall. SpawnBag.recall = function(fast) if fast then internal.deleteSpawned() @@ -194,30 +194,30 @@ do local thick = 0.05 Global.setVectorLines({ { - points = { {recallZone.upperLeft.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.lowerRight.z} }, - color = {1,0,0}, - thickness = thick, - rotation = {0,0,0}, + points = { {recallZone.upperLeft.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.lowerRight.z} }, + color = {1,0,0}, + thickness = thick, + rotation = {0,0,0} }, { - points = { {recallZone.upperLeft.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.lowerRight.z} }, - color = {1,0,0}, - thickness = thick, - rotation = {0,0,0}, + points = { {recallZone.upperLeft.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.lowerRight.z} }, + color = {1,0,0}, + thickness = thick, + rotation = {0,0,0} }, { - points = { {recallZone.lowerRight.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.upperLeft.z} }, - color = {1,0,0}, - thickness = thick, - rotation = {0,0,0}, + points = { {recallZone.lowerRight.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.upperLeft.z} }, + color = {1,0,0}, + thickness = thick, + rotation = {0,0,0} }, { - points = { {recallZone.lowerRight.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.upperLeft.z} }, - color = {1,0,0}, - thickness = thick, - rotation = {0,0,0}, - }, - }) + points = { {recallZone.lowerRight.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.upperLeft.z} }, + color = {1,0,0}, + thickness = thick, + rotation = {0,0,0} + } + }) end end diff --git a/src/playercards/cards/EmpiricalHypothesis.ttslua b/src/playercards/cards/EmpiricalHypothesis.ttslua index 22455fca..1c1d80da 100644 --- a/src/playercards/cards/EmpiricalHypothesis.ttslua +++ b/src/playercards/cards/EmpiricalHypothesis.ttslua @@ -50,7 +50,7 @@ function onLoad(savedData) end -- marks a button as active ----@param index Number Index of the button to mark (starts at 0 from the top) +---@param index number Index of the button to mark (starts at 0 from the top) function selectButton(index) local lastindex = #hypothesisList - 1 for i = 0, lastindex do diff --git a/src/playercards/customizable/UpgradeSheetLibrary.ttslua b/src/playercards/customizable/UpgradeSheetLibrary.ttslua index e28f04a7..07e1647a 100644 --- a/src/playercards/customizable/UpgradeSheetLibrary.ttslua +++ b/src/playercards/customizable/UpgradeSheetLibrary.ttslua @@ -219,7 +219,7 @@ function updateTextField(rowIndex) end end -function clickCheckbox(row, col, buttonIndex) +function clickCheckbox(row, col) if selectedUpgrades[row] == nil then selectedUpgrades[row] = { } selectedUpgrades[row].xp = 0 diff --git a/src/playermat/InvestigatorSkillTracker.ttslua b/src/playermat/InvestigatorSkillTracker.ttslua index 1f20685c..c709b1a1 100644 --- a/src/playermat/InvestigatorSkillTracker.ttslua +++ b/src/playermat/InvestigatorSkillTracker.ttslua @@ -44,7 +44,7 @@ function updateButtonLabel(index) end -- update the stats to the provided values ----@param newStats Table Contains the new values for the stats: {Willpower, Intellect, Fight, Agility} +---@param newStats table Contains the new values for the stats: {Willpower, Intellect, Fight, Agility} function updateStats(newStats) if newStats and #newStats == 4 then stats = newStats diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 0bd09f50..f3f551f6 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -190,8 +190,8 @@ function doNotReady(card) end -- rounds a number to the specified amount of decimal places ----@param num Number Initial value ----@param numDecimalPlaces Number Amount of decimal places +---@param num number Initial value +---@param numDecimalPlaces number Amount of decimal places function round(num, numDecimalPlaces) local mult = 10^(numDecimalPlaces or 0) return math.floor(num * mult + 0.5) / mult @@ -202,7 +202,7 @@ end --------------------------------------------------------- -- handles discarding for a list of objects ----@param objList Table List of objects to discard +---@param objList table List of objects to discard function discardListOfObjects(objList) for _, obj in ipairs(objList) do if obj.type == "Card" or obj.type == "Deck" then @@ -447,7 +447,6 @@ function flipTopCardFromDeck() Wait.time(function() local deckAreaObjects = getDeckAreaObjects() if deckAreaObjects.topCard then - return elseif deckAreaObjects.draw then if deckAreaObjects.draw.type == "Card" then deckAreaObjects.draw.flip() @@ -758,7 +757,7 @@ end --------------------------------------------------------- -- updates the specific owned counter ----@param param Table Contains the information to update: +---@param param table Contains the information to update: --- type: String Counter to target --- newValue: Number Value to set the counter to --- modifier: Number If newValue is not provided, the existing value will be adjusted by this modifier @@ -772,7 +771,7 @@ function updateCounter(param) end -- returns the resource counter amount ----@param type String Counter to target +---@param type string Counter to target function getCounterValue(type) return ownedObjects[type].getVar("val") end @@ -804,7 +803,7 @@ function returnGlobalDiscardPosition() end -- Sets this playermat's draw 1 button to visible ----@param visible Boolean. Whether the draw 1 button should be visible +---@param visible boolean Whether the draw 1 button should be visible function showDrawButton(visible) isDrawButtonVisible = visible @@ -833,7 +832,7 @@ function showDrawButton(visible) end -- shows / hides a clickable clue counter for this playmat and sets the correct amount of clues ----@param showCounter Boolean Whether the clickable clue counter should be visible +---@param showCounter boolean Whether the clickable clue counter should be visible function clickableClues(showCounter) local clickerPos = ownedObjects.ClickableClueCounter.getPosition() local clueCount = 0 @@ -871,7 +870,7 @@ function removeClues() end -- reports the clue count ----@param useClickableCounters Boolean Controls which type of counter is getting checked +---@param useClickableCounters boolean Controls which type of counter is getting checked function getClueCount(useClickableCounters) if useClickableCounters then return ownedObjects.ClickableClueCounter.getVar("val") @@ -880,11 +879,10 @@ function getClueCount(useClickableCounters) end end --- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes +-- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes -- is true, the main card slot snap points will only snap assets, while the investigator area point --- will only snap Investigators. If matchTypes is false, snap points will be reset to snap all --- cards. ----@param matchTypes Boolean. Whether snap points should only snap for the matching card types. +-- will only snap Investigators. If matchTypes is false, snap points will be reset to snap all cards. +---@param matchTypes boolean Whether snap points should only snap for the matching card types. function setLimitSnapsByType(matchTypes) local snaps = self.getSnapPoints() for i, snap in ipairs(snaps) do @@ -918,10 +916,10 @@ function setLimitSnapsByType(matchTypes) end -- Simple method to check if the given point is in a specified area. Local use only, ----@param point Vector Point to check, only x and z values are relevant ----@param bounds Table Defined area to see if the point is within. See MAIN_PLAY_AREA for sample +---@param point tts__Vector Point to check, only x and z values are relevant +---@param bounds table Defined area to see if the point is within. See MAIN_PLAY_AREA for sample -- bounds definition. ----@return Boolean True if the point is in the area defined by bounds +---@return boolean: True if the point is in the area defined by bounds function inArea(point, bounds) return (point.x < bounds.upperLeft.x and point.x > bounds.lowerRight.x diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index ed4a5366..fb56c464 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -4,8 +4,8 @@ do local searchLib = require("util/SearchLib") -- Convenience function to look up a mat's object by color, or get all mats. - ---@param matColor String Color of the playmat - White, Orange, Green, Red or All - ---@return array Table Single-element if only single playmat is requested + ---@param matColor string Color of the playmat - White, Orange, Green, Red or All + ---@return table: Single-element if only single playmat is requested local function getMatForColor(matColor) if matColor == "All" then return guidReferenceApi.getObjectsByType("Playermat") @@ -15,7 +15,7 @@ do end -- Returns the color of the closest playmat - ---@param startPos Table Starting position to get the closest mat from + ---@param startPos table Starting position to get the closest mat from PlaymatApi.getMatColorByPosition = function(startPos) local result, smallestDistance for matColor, mat in pairs(getMatForColor("All")) do @@ -29,7 +29,7 @@ do end -- Returns the color of the player's hand that is seated next to the playmat - ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") + ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getPlayerColor = function(matColor) for _, mat in pairs(getMatForColor(matColor)) do return mat.getVar("playerColor") @@ -37,7 +37,7 @@ do end -- Returns the color of the playmat that owns the playercolor's hand - ---@param handColor String Color of the playmat + ---@param handColor string Color of the playmat PlaymatApi.getMatColor = function(handColor) for matColor, mat in pairs(getMatForColor("All")) do local playerColor = mat.getVar("playerColor") @@ -48,7 +48,7 @@ do end -- Returns if there is the card "Dream-Enhancing Serum" on the requested playmat - ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") + ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.isDES = function(matColor) for _, mat in pairs(getMatForColor(matColor)) do return mat.getVar("isDES") @@ -56,7 +56,7 @@ do end -- Performs a search of the deck area of the requested playmat and returns the result as table - ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") + ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getDeckAreaObjects = function(matColor) for _, mat in pairs(getMatForColor(matColor)) do return mat.call("getDeckAreaObjects") @@ -64,7 +64,7 @@ do end -- Flips the top card of the deck (useful after deck manipulation for Norman Withers) - ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") + ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.flipTopCardFromDeck = function(matColor) for _, mat in pairs(getMatForColor(matColor)) do return mat.call("flipTopCardFromDeck") @@ -72,7 +72,7 @@ do end -- Returns the position of the discard pile of the requested playmat - ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") + ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getDiscardPosition = function(matColor) for _, mat in pairs(getMatForColor(matColor)) do return mat.call("returnGlobalDiscardPosition") @@ -80,8 +80,8 @@ do end -- Transforms a local position into a global position - ---@param localPos Table Local position to be transformed - ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") + ---@param localPos table Local position to be transformed + ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.transformLocalPosition = function(localPos, matColor) for _, mat in pairs(getMatForColor(matColor)) do return mat.positionToWorld(localPos) @@ -89,7 +89,7 @@ do end -- Returns the rotation of the requested playmat - ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") + ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.returnRotation = function(matColor) for _, mat in pairs(getMatForColor(matColor)) do return mat.getRotation() @@ -97,8 +97,8 @@ do end -- Returns a table with spawn data (position and rotation) for a helper object - ---@param matColor String Color of the playmat - White, Orange, Green, Red or All - ---@param helperName String Name of the helper object + ---@param matColor string Color of the playmat - White, Orange, Green, Red or All + ---@param helperName string Name of the helper object PlaymatApi.getHelperSpawnData = function(matColor, helperName) local resultTable = {} local localPositionTable = { @@ -117,8 +117,8 @@ do -- Triggers the Upkeep for the requested playmat - ---@param matColor String Color of the playmat - White, Orange, Green, Red or All - ---@param playerColor String Color of the calling player (for messages) + ---@param matColor string Color of the playmat - White, Orange, Green, Red or All + ---@param playerColor string Color of the calling player (for messages) PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor) for _, mat in pairs(getMatForColor(matColor)) do mat.call("doUpkeepFromHotkey", playerColor) @@ -126,8 +126,8 @@ do end -- Handles discarding for the requested playmat for the provided list of objects - ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") - ---@param objList Table List of objects to discard + ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All") + ---@param objList table List of objects to discard PlaymatApi.discardListOfObjects = function(matColor, objList) for _, mat in pairs(getMatForColor(matColor)) do mat.call("discardListOfObjects", objList) @@ -135,7 +135,7 @@ do end -- Returns the active investigator id - ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") + ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.returnInvestigatorId = function(matColor) for _, mat in pairs(getMatForColor(matColor)) do return mat.getVar("activeInvestigatorId") @@ -146,8 +146,8 @@ do -- matchTypes is true, the main card slot snap points will only snap assets, while the -- investigator area point will only snap Investigators. If matchTypes is false, snap points will -- be reset to snap all cards. - ---@param matchCardTypes Boolean Whether snap points should only snap for the matching card types - ---@param matColor String Color of the playmat - White, Orange, Green, Red or All + ---@param matchCardTypes boolean Whether snap points should only snap for the matching card types + ---@param matColor string Color of the playmat - White, Orange, Green, Red or All PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor) for _, mat in pairs(getMatForColor(matColor)) do mat.call("setLimitSnapsByType", matchCardTypes) @@ -155,8 +155,8 @@ do end -- Sets the requested playmat's draw 1 button to visible - ---@param isDrawButtonVisible Boolean Whether the draw 1 button should be visible or not - ---@param matColor String Color of the playmat - White, Orange, Green, Red or All + ---@param isDrawButtonVisible boolean Whether the draw 1 button should be visible or not + ---@param matColor string Color of the playmat - White, Orange, Green, Red or All PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor) for _, mat in pairs(getMatForColor(matColor)) do mat.call("showDrawButton", isDrawButtonVisible) @@ -164,8 +164,8 @@ do end -- Shows or hides the clickable clue counter for the requested playmat - ---@param showCounter Boolean Whether the clickable counter should be present or not - ---@param matColor String Color of the playmat - White, Orange, Green, Red or All + ---@param showCounter boolean Whether the clickable counter should be present or not + ---@param matColor string Color of the playmat - White, Orange, Green, Red or All PlaymatApi.clickableClues = function(showCounter, matColor) for _, mat in pairs(getMatForColor(matColor)) do mat.call("clickableClues", showCounter) @@ -173,7 +173,7 @@ do end -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat - ---@param matColor String Color of the playmat - White, Orange, Green, Red or All + ---@param matColor string Color of the playmat - White, Orange, Green, Red or All PlaymatApi.removeClues = function(matColor) for _, mat in pairs(getMatForColor(matColor)) do mat.call("removeClues") @@ -181,7 +181,7 @@ do end -- Reports the clue count for the requested playmat - ---@param useClickableCounters Boolean Controls which type of counter is getting checked + ---@param useClickableCounters boolean Controls which type of counter is getting checked PlaymatApi.getClueCount = function(useClickableCounters, matColor) local count = 0 for _, mat in pairs(getMatForColor(matColor)) do @@ -191,10 +191,10 @@ do end -- updates the specified owned counter - ---@param matColor String Color of the playmat - White, Orange, Green, Red or All - ---@param type String Counter to target - ---@param newValue Number Value to set the counter to - ---@param modifier Number If newValue is not provided, the existing value will be adjusted by this modifier + ---@param matColor string Color of the playmat - White, Orange, Green, Red or All + ---@param type string Counter to target + ---@param newValue number Value to set the counter to + ---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier PlaymatApi.updateCounter = function(matColor, type, newValue, modifier) for _, mat in pairs(getMatForColor(matColor)) do mat.call("updateCounter", { type = type, newValue = newValue, modifier = modifier }) @@ -202,8 +202,8 @@ do end -- triggers the draw function for the specified playmat - ---@param matColor String Color of the playmat - White, Orange, Green, Red or All - ---@param number Number Amount of cards to draw + ---@param matColor string Color of the playmat - White, Orange, Green, Red or All + ---@param number number Amount of cards to draw PlaymatApi.drawCardsWithReshuffle = function(matColor, number) for _, mat in pairs(getMatForColor(matColor)) do mat.call("drawCardsWithReshuffle", number) @@ -211,8 +211,8 @@ do end -- returns the resource counter amount - ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") - ---@param type String Counter to target + ---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All") + ---@param type string Counter to target PlaymatApi.getCounterValue = function(matColor, type) for _, mat in pairs(getMatForColor(matColor)) do return mat.call("getCounterValue", type) @@ -236,7 +236,7 @@ do end -- resets the specified skill tracker to "1, 1, 1, 1" - ---@param matColor String Color of the playmat - White, Orange, Green, Red or All + ---@param matColor string Color of the playmat - White, Orange, Green, Red or All PlaymatApi.resetSkillTracker = function(matColor) for _, mat in pairs(getMatForColor(matColor)) do mat.call("resetSkillTracker") @@ -244,8 +244,8 @@ do end -- finds all objects on the playmat and associated set aside zone and returns a table - ---@param matColor String Color of the playmat - White, Orange, Green, Red or All - ---@param filter String Name of the filte function (see util/SearchLib) + ---@param matColor string Color of the playmat - White, Orange, Green, Red or All + ---@param filter string Name of the filte function (see util/SearchLib) PlaymatApi.searchAroundPlaymat = function(matColor, filter) local objList = {} for _, mat in pairs(getMatForColor(matColor)) do @@ -257,7 +257,7 @@ do end -- Discard a non-hidden card from the corresponding player's hand - ---@param matColor String Color of the playmat - White, Orange, Green, Red or All + ---@param matColor string Color of the playmat - White, Orange, Green, Red or All PlaymatApi.doDiscardOne = function(matColor) for _, mat in pairs(getMatForColor(matColor)) do mat.call("doDiscardOne") diff --git a/src/playermat/Zones.ttslua b/src/playermat/Zones.ttslua index eb12df86..551da198 100644 --- a/src/playermat/Zones.ttslua +++ b/src/playermat/Zones.ttslua @@ -116,9 +116,9 @@ do zoneData["Green"] = zoneData["White"] -- Gets the global position for the given zone on the specified player mat. - ---@param playerColor: Color name of the player mat to get the zone position for (e.g. "Red") - ---@param zoneName: Name of the zone to get the position for. See Zones object documentation for a list of valid zones. - ---@return: Global position table, or nil if an invalid player color or zone is specified + ---@param playerColor string Color name of the player mat to get the zone position for (e.g. "Red") + ---@param zoneName string Name of the zone to get the position for. See Zones object documentation for a list of valid zones. + ---@return tts__Vector|nil: Global position table, or nil if an invalid player color or zone is specified Zones.getZonePosition = function(playerColor, zoneName) if (playerColor ~= "Red" and playerColor ~= "Orange" @@ -130,9 +130,9 @@ do end -- Return the global rotation for a card on the given player mat, based on its zone. - ---@param playerColor: Color name of the player mat to get the rotation for (e.g. "Red") - ---@param zoneName: Name of the zone. See Zones object documentation for a list of valid zones. - ---@return: Global rotation vector for the given card. This will include the + ---@param playerColor string Color name of the player mat to get the rotation for (e.g. "Red") + ---@param zoneName string Name of the zone. See Zones object documentation for a list of valid zones. + ---@return tts__Vector: Global rotation vector for the given card. This will include the -- Y rotation to orient the card on the given player mat as well as a -- Z rotation to place the card face up or face down. Zones.getDefaultCardRotation = function(playerColor, zoneName) diff --git a/src/util/DeckLib.ttslua b/src/util/DeckLib.ttslua index 15c24ece..69d85851 100644 --- a/src/util/DeckLib.ttslua +++ b/src/util/DeckLib.ttslua @@ -3,9 +3,9 @@ do local searchLib = require("util/SearchLib") -- places a card/deck at a position or merges into an existing deck - ---@param obj TTSObject Object to move - ---@param pos Table New position for the object - ---@param rot Table New rotation for the object (optional) + ---@param obj tts__Object Object to move + ---@param pos table New position for the object + ---@param rot table New rotation for the object (optional) DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot) if obj == nil or pos == nil then return end diff --git a/src/util/SearchLib.ttslua b/src/util/SearchLib.ttslua index 13550179..fbf19661 100644 --- a/src/util/SearchLib.ttslua +++ b/src/util/SearchLib.ttslua @@ -10,14 +10,17 @@ do } -- performs the actual search and returns a filtered list of object references - ---@param pos Table Global position - ---@param rot Table 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 + ---@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) - if filter then filter = filterFunctions[filter] end + local filterFunc + if filter then + filterFunc = filterFunctions[filter] + end local searchResult = Physics.cast({ origin = pos, direction = direction or { 0, 1, 0 }, @@ -30,7 +33,7 @@ do -- filtering the result local objList = {} for _, v in ipairs(searchResult) do - if not filter or filter(v.hit_object) then + if not filter or filterFunc(v.hit_object) then table.insert(objList, v.hit_object) end end