diff --git a/src/accessories/CampaignImporterExporter.ttslua b/src/accessories/CampaignImporterExporter.ttslua index fe7834a7..5d7c9a4e 100644 --- a/src/accessories/CampaignImporterExporter.ttslua +++ b/src/accessories/CampaignImporterExporter.ttslua @@ -1,3 +1,9 @@ +local blessCurseApi = require("chaosbag/BlessCurseManagerApi") +local chaosBagApi = require("chaosbag/ChaosBagApi") +local deckImporterApi = require("arkhamdb/DeckImporterApi") +local optionPanelApi = require("core/OptionPanelApi") +local playAreaApi = require("core/PlayAreaApi") + local campaignTokenData = { GUID = "51b1c9", Name = "Custom_Model", @@ -46,14 +52,7 @@ local DAMAGE_HORROR_GUIDS = { "468e88"; "0257d9"; "7b5729"; "beb964"; } -local chaosBagApi = require("chaosbag/ChaosBagApi") -local playAreaApi = require("core/PlayAreaApi") -local deckImporterApi = require("arkhamdb/DeckImporterApi") -local optionPanelApi = require("core/OptionPanelApi") -local blessCurseApi = require("chaosbag/BlessCurseManagerApi") - local TOUR_GUID = "0e5aa8" - local campaignBoxGUID function onLoad(save_state) diff --git a/src/accessories/ChaosBagManager.ttslua b/src/accessories/ChaosBagManager.ttslua index 2fc700d7..dc1a441d 100644 --- a/src/accessories/ChaosBagManager.ttslua +++ b/src/accessories/ChaosBagManager.ttslua @@ -1,3 +1,5 @@ +local chaosBagApi = require("chaosbag/ChaosBagApi") + local TOKEN_IDS = { -- first row "p1", "0", "m1", "m2", "m3", "m4", @@ -34,7 +36,6 @@ buttonParameters.height = 300 local name local tokens = {} -local chaosBagApi = require("chaosbag/ChaosBagApi") function onLoad() -- create buttons for tokens diff --git a/src/accessories/CleanUpHelper.ttslua b/src/accessories/CleanUpHelper.ttslua index 4200bf7a..3d25e52c 100644 --- a/src/accessories/CleanUpHelper.ttslua +++ b/src/accessories/CleanUpHelper.ttslua @@ -2,12 +2,13 @@ - sets counters to default values (resources and doom) or trauma values (health and sanity, if not disabled) from campaign log - puts everything on playmats and hands into respective trashcans - use the IGNORE_TAG to exclude objects from tidying (default: "CleanUpHelper_Ignore")]] -local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") -local soundCubeApi = require("core/SoundCubeApi") -local playmatApi = require("playermat/PlaymatApi") + local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") local chaosBagApi = require("chaosbag/ChaosBagApi") local playAreaApi = require("core/PlayAreaApi") +local playmatApi = require("playermat/PlaymatApi") +local soundCubeApi = require("core/SoundCubeApi") +local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") -- these objects will be ignored local IGNORE_GUIDS = { diff --git a/src/accessories/TokenArranger.ttslua b/src/accessories/TokenArranger.ttslua index 160552de..8111b455 100644 --- a/src/accessories/TokenArranger.ttslua +++ b/src/accessories/TokenArranger.ttslua @@ -1,5 +1,5 @@ -local mythosAreaApi = require("core/MythosAreaApi") local chaosBagApi = require("chaosbag/ChaosBagApi") +local mythosAreaApi = require("core/MythosAreaApi") -- common parameters local buttonParameters = {} diff --git a/src/arkhamdb/ArkhamDb.ttslua b/src/arkhamdb/ArkhamDb.ttslua index 73abd49c..0b8c9621 100644 --- a/src/arkhamdb/ArkhamDb.ttslua +++ b/src/arkhamdb/ArkhamDb.ttslua @@ -1,6 +1,7 @@ do - local playAreaApi = require("core/PlayAreaApi") local allCardsBagApi = require("playercards/AllCardsBagApi") + local playAreaApi = require("core/PlayAreaApi") + local ArkhamDb = { } local internal = { } diff --git a/src/arkhamdb/DeckImporterApi.ttslua b/src/arkhamdb/DeckImporterApi.ttslua index 73fc556f..3250bf97 100644 --- a/src/arkhamdb/DeckImporterApi.ttslua +++ b/src/arkhamdb/DeckImporterApi.ttslua @@ -2,7 +2,6 @@ do local DeckImporterApi = {} local DECK_IMPORTER_GUID = "a28140" - -- 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: @@ -22,7 +21,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 + ---@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 diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index 2deb416d..a258be00 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -1,10 +1,10 @@ require("arkhamdb/DeckImporterUi") require("playercards/PlayerCardSpawner") -local playmatApi = require("playermat/PlaymatApi") -local playAreaApi = require("core/PlayAreaApi") local allCardsBagApi = require("playercards/AllCardsBagApi") local arkhamDb = require("arkhamdb/ArkhamDb") +local playAreaApi = require("core/PlayAreaApi") +local playmatApi = require("playermat/PlaymatApi") local zones = require("playermat/Zones") function onLoad(script_state) diff --git a/src/arkhamdb/DeckImporterUi.ttslua b/src/arkhamdb/DeckImporterUi.ttslua index 59ad1ac8..10470d0e 100644 --- a/src/arkhamdb/DeckImporterUi.ttslua +++ b/src/arkhamdb/DeckImporterUi.ttslua @@ -1,3 +1,5 @@ +local allCardsBagApi = require("playercards/AllCardsBagApi") + local INPUT_FIELD_HEIGHT = 340 local INPUT_FIELD_WIDTH = 1500 local FIELD_COLOR = { 0.9, 0.7, 0.5 } @@ -23,8 +25,6 @@ local privateDeck = true local loadNewestDeck = true local loadInvestigators = false -local allCardsBagApi = require("playercards/AllCardsBagApi") - -- 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: @@ -48,7 +48,7 @@ function getUiState() 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 +---@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 diff --git a/src/chaosbag/BlessCurseManager.ttslua b/src/chaosbag/BlessCurseManager.ttslua index 696df8a6..b4ec9596 100644 --- a/src/chaosbag/BlessCurseManager.ttslua +++ b/src/chaosbag/BlessCurseManager.ttslua @@ -1,3 +1,4 @@ +local chaosBagApi = require("chaosbag/ChaosBagApi") local tokenArrangerApi = require("accessories/TokenArrangerApi") -- common button parameters @@ -23,8 +24,6 @@ local FONT_COLOR = { local whitespace = " " local updating -local chaosBagApi = require("chaosbag/ChaosBagApi") - --------------------------------------------------------- -- creating buttons and menus + initializing tables --------------------------------------------------------- diff --git a/src/core/GameKeyHandler.ttslua b/src/core/GameKeyHandler.ttslua index 58452e60..192defd7 100644 --- a/src/core/GameKeyHandler.ttslua +++ b/src/core/GameKeyHandler.ttslua @@ -1,7 +1,7 @@ local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") +local optionPanelApi = require("core/OptionPanelApi") local playmatApi = require("playermat/PlaymatApi") local victoryDisplayApi = require("core/VictoryDisplayApi") -local optionPanelApi = require("core/OptionPanelApi") function onLoad() addHotkey("Add Doom to Agenda", addDoomToAgenda) diff --git a/src/core/MythosArea.ttslua b/src/core/MythosArea.ttslua index 5cac0f66..46b4fda7 100644 --- a/src/core/MythosArea.ttslua +++ b/src/core/MythosArea.ttslua @@ -1,7 +1,7 @@ local playAreaApi = require("core/PlayAreaApi") local tokenArrangerApi = require("accessories/TokenArrangerApi") -local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") local tokenChecker = require("core/token/TokenChecker") +local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") local ENCOUNTER_DECK_AREA = { upperLeft = { x = 0.9, z = 0.42 }, diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua index 66784904..ad6a5b7a 100644 --- a/src/core/PlayAreaApi.ttslua +++ b/src/core/PlayAreaApi.ttslua @@ -1,6 +1,5 @@ do local PlayAreaApi = { } - local PLAY_AREA_GUID = "721ba2" local INVESTIGATOR_COUNTER_GUID = "f182ee" diff --git a/src/core/PlayAreaSelector.ttslua b/src/core/PlayAreaSelector.ttslua index 84749458..1c357733 100644 --- a/src/core/PlayAreaSelector.ttslua +++ b/src/core/PlayAreaSelector.ttslua @@ -1,6 +1,7 @@ -local controlActive = false local playAreaApi = require("core/PlayAreaApi") +local controlActive = false + -- parameters for open/close button for reusing local buttonParameters = {} buttonParameters.function_owner = self diff --git a/src/core/SoundCubeApi.ttslua b/src/core/SoundCubeApi.ttslua index 89222f3e..de97f117 100644 --- a/src/core/SoundCubeApi.ttslua +++ b/src/core/SoundCubeApi.ttslua @@ -1,6 +1,5 @@ do local SoundCubeApi = {} - local internal = {} -- this table links the name of a trigger effect to its index local soundIndices = { @@ -9,14 +8,14 @@ do ["Dark Souls"] = 2 } - internal.playTriggerEffect = function(index) + local function playTriggerEffect(index) getObjectsWithTag("SoundCube")[1].AssetBundle.playTriggerEffect(index) end -- plays the by name requested sound ---@param soundName String Name of the sound to play SoundCubeApi.playSoundByName = function(soundName) - internal.playTriggerEffect(soundIndices[soundName]) + playTriggerEffect(soundIndices[soundName]) end return SoundCubeApi diff --git a/src/core/VictoryDisplay.ttslua b/src/core/VictoryDisplay.ttslua index ebdb9faf..bf8a5502 100644 --- a/src/core/VictoryDisplay.ttslua +++ b/src/core/VictoryDisplay.ttslua @@ -1,14 +1,17 @@ +local chaosBagApi = require("chaosbag/ChaosBagApi") local playAreaApi = require("core/PlayAreaApi") local tokenChecker = require("core/token/TokenChecker") + local pendingCall = false local messageSent = {} local missingData = {} local countedVP = {} + local highlightMissing = false local highlightCounted = false + local TRASHCAN local TRASHCAN_GUID = "70b9f6" -local chaosBagApi = require("chaosbag/ChaosBagApi") -- button creation when loading the game function onLoad() diff --git a/src/core/token/TokenManager.ttslua b/src/core/token/TokenManager.ttslua index 9e27b1bb..3687ee64 100644 --- a/src/core/token/TokenManager.ttslua +++ b/src/core/token/TokenManager.ttslua @@ -1,7 +1,7 @@ do - local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") - local playAreaApi = require("core/PlayAreaApi") local optionPanelApi = require("core/OptionPanelApi") + local playAreaApi = require("core/PlayAreaApi") + local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") local PLAYER_CARD_TOKEN_OFFSETS = { [1] = { diff --git a/src/core/token/TokenSpawnTrackerApi.ttslua b/src/core/token/TokenSpawnTrackerApi.ttslua index bd9a559e..dd8d7002 100644 --- a/src/core/token/TokenSpawnTrackerApi.ttslua +++ b/src/core/token/TokenSpawnTrackerApi.ttslua @@ -1,6 +1,5 @@ do local TokenSpawnTracker = { } - local SPAWN_TRACKER_GUID = "e3ffc9" TokenSpawnTracker.hasSpawnedTokens = function(cardGuid) diff --git a/src/playercards/CardSearch.ttslua b/src/playercards/CardSearch.ttslua index fd4f7e3d..c31f5417 100644 --- a/src/playercards/CardSearch.ttslua +++ b/src/playercards/CardSearch.ttslua @@ -1,11 +1,3 @@ --- Search-A-Card --- made by: Chr1Z --- description: spawns the card(s) with the specified name -information = { - version = "1.2", - last_updated = "12.11.2022" -} - require("playercards/PlayerCardSpawner") local allCardsBagApi = require("playercards/AllCardsBagApi") @@ -17,9 +9,11 @@ buttonParameters.width = 1200 buttonParameters.font_size = 75 local BUTTON_LABELS = {} + BUTTON_LABELS["spawn"] = {} BUTTON_LABELS["spawn"][true] = "Mode: Spawn all matching cards " BUTTON_LABELS["spawn"][false] = "Mode: Spawn first matching card" + BUTTON_LABELS["search"] = {} BUTTON_LABELS["search"][true] = "Mode: Name matches search term" BUTTON_LABELS["search"][false] = "Mode: Name contains search term" @@ -35,13 +29,15 @@ inputParameters.height = 130 inputParameters.font_size = 107 -- main code -function onSave() return JSON.encode({ spawnAll, searchExact, inputParameters.value }) end +function onSave() + return JSON.encode({ spawnAll, searchExact, inputParameters.value }) +end -function onLoad(saved_data) - local loaded_data = JSON.decode(saved_data) - spawnAll = loaded_data[1] or false - searchExact = loaded_data[2] or false - inputParameters.value = loaded_data[3] or "" +function onLoad(savedData) + local loadedData = JSON.decode(savedData) + spawnAll = loadedData[1] or false + searchExact = loadedData[2] or false + inputParameters.value = loadedData[3] or "" -- index 0: button for spawn mode buttonParameters.click_function = "search" @@ -62,11 +58,6 @@ function onLoad(saved_data) self.createButton(buttonParameters) self.createInput(inputParameters) - self.addContextMenuItem("More Information", function() - printToAll("------------------------------", "White") - printToAll("Search-A-Card v" .. information["version"] .. " by Chr1Z", "Orange") - printToAll("last updated: " .. information["last_updated"], "White") - end) end function spawnMode() diff --git a/src/playercards/CardsThatSealTokens.ttslua b/src/playercards/CardsThatSealTokens.ttslua index bc18d9d6..82844f69 100644 --- a/src/playercards/CardsThatSealTokens.ttslua +++ b/src/playercards/CardsThatSealTokens.ttslua @@ -69,8 +69,9 @@ Thus it should be implemented like this: ----------------------------------------------------------]] local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") -local tokenArrangerApi = require("accessories/TokenArrangerApi") local chaosBagApi = require("chaosbag/ChaosBagApi") +local tokenArrangerApi = require("accessories/TokenArrangerApi") + local sealedTokens = {} local ID_URL_MAP = {} local tokensInBag = {} diff --git a/src/playercards/PlayerCardPanel.ttslua b/src/playercards/PlayerCardPanel.ttslua index 161ddf6b..eaf5eb1b 100644 --- a/src/playercards/PlayerCardPanel.ttslua +++ b/src/playercards/PlayerCardPanel.ttslua @@ -1,7 +1,8 @@ require("playercards/PlayerCardPanelData") -local spawnBag = require("playercards/SpawnBag") -local arkhamDb = require("arkhamdb/ArkhamDb") + local allCardsBagApi = require("playercards/AllCardsBagApi") +local arkhamDb = require("arkhamdb/ArkhamDb") +local spawnBag = require("playercards/SpawnBag") -- Size and position information for the three rows of class buttons local CIRCLE_BUTTON_SIZE = 250 diff --git a/src/playercards/PlayerCardSpawner.ttslua b/src/playercards/PlayerCardSpawner.ttslua index 089842cc..8ed82318 100644 --- a/src/playercards/PlayerCardSpawner.ttslua +++ b/src/playercards/PlayerCardSpawner.ttslua @@ -1,4 +1,3 @@ - -- Amount to shift for the next card (zShift) or next row of cards (xShift) -- Note that the table rotation is weird, and the X axis is vertical while the -- Z axis is horizontal diff --git a/src/playercards/SpawnBag.ttslua b/src/playercards/SpawnBag.ttslua index 5591ec53..06ef1e28 100644 --- a/src/playercards/SpawnBag.ttslua +++ b/src/playercards/SpawnBag.ttslua @@ -23,14 +23,14 @@ require("playercards/PlayerCardSpawner") -- } -- See BondedBag.ttslua for an example do + local allCardsBagApi = require("playercards/AllCardsBagApi") + local SpawnBag = { } local internal = { } -- To assist debugging, will draw a box around the recall zone when it's set up local SHOW_RECALL_ZONE = false - local allCardsBagApi = require("playercards/AllCardsBagApi") - -- Distance to expand the recall zone around any added object. local RECALL_BUFFER_X = 0.9 local RECALL_BUFFER_Z = 0.5 diff --git a/src/playermat/InvestigatorSkillTracker.ttslua b/src/playermat/InvestigatorSkillTracker.ttslua index 07e61666..5abf7b19 100644 --- a/src/playermat/InvestigatorSkillTracker.ttslua +++ b/src/playermat/InvestigatorSkillTracker.ttslua @@ -1,7 +1,3 @@ --- Stat Tracker --- made by: Chr1Z --- description: helps tracking the stats of your investigator - local BUTTON_PARAMETERS = {} BUTTON_PARAMETERS.function_owner = self BUTTON_PARAMETERS.height = 650 @@ -15,52 +11,52 @@ function onSave() return JSON.encode(stats) end -- load stats and make buttons (left to right) function onLoad(saved_data) - stats = JSON.decode(saved_data) or { 1, 1, 1, 1 } + stats = JSON.decode(saved_data) or { 1, 1, 1, 1 } - for i = 1, 4 do - BUTTON_PARAMETERS.label = stats[i] .. " " - BUTTON_PARAMETERS.position.x = BUTTON_PARAMETERS.position.x + 1.91 - BUTTON_PARAMETERS.click_function = attachIndex("button_click", i) - self.createButton(BUTTON_PARAMETERS) - end + for i = 1, 4 do + BUTTON_PARAMETERS.label = stats[i] .. " " + BUTTON_PARAMETERS.position.x = BUTTON_PARAMETERS.position.x + 1.91 + BUTTON_PARAMETERS.click_function = attachIndex("button_click", i) + self.createButton(BUTTON_PARAMETERS) + end - self.addContextMenuItem("Reset to 1s", function() updateStats({ 1, 1, 1, 1 }) end) + self.addContextMenuItem("Reset to 1s", function() updateStats({ 1, 1, 1, 1 }) end) end -- helper function to carry index function attachIndex(click_function, index) - local fn_name = click_function .. index - _G[fn_name] = function(obj, player_color, isRightClick) - _G[click_function](obj, player_color, isRightClick, index) - end - return fn_name + local fn_name = click_function .. index + _G[fn_name] = function(obj, player_color, isRightClick) + _G[click_function](obj, player_color, isRightClick, index) + end + return fn_name end function button_click(_, _, isRightClick, index) - stats[index] = math.min(math.max(stats[index] + (isRightClick and -1 or 1), 0), 99) - changeButton(index) + stats[index] = math.min(math.max(stats[index] + (isRightClick and -1 or 1), 0), 99) + changeButton(index) end function changeButton(index) - local font_size = BUTTON_PARAMETERS.font_size - local whitespace = " " + local font_size = BUTTON_PARAMETERS.font_size + local whitespace = " " - if stats[index] > 9 then - font_size = BUTTON_PARAMETERS.font_size * 0.65 - whitespace = " " - end + if stats[index] > 9 then + font_size = BUTTON_PARAMETERS.font_size * 0.65 + whitespace = " " + end - self.editButton({ index = index - 1, label = stats[index] .. whitespace, font_size = font_size }) + self.editButton({ index = index - 1, label = stats[index] .. whitespace, font_size = font_size }) end -- formatting of "newStats": {Willpower, Intellect, Fight, Agility} function updateStats(newStats) - if newStats and #newStats == 4 then - stats = newStats - elseif newStats then - printToAll("Provided new stats are incomplete or incorrectly formatted.", "Red") - return - end + if newStats and #newStats == 4 then + stats = newStats + elseif newStats then + printToAll("Provided new stats are incomplete or incorrectly formatted.", "Red") + return + end - for i = 1, 4 do changeButton(i) end + for i = 1, 4 do changeButton(i) end end