Merge pull request #382 from argonui/top-of-file-cleanup

Script file cleanup
This commit is contained in:
Chr1Z 2023-09-26 17:58:56 +02:00 committed by GitHub
commit 8be0a0e8fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 80 additions and 91 deletions

View File

@ -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 = { local campaignTokenData = {
GUID = "51b1c9", GUID = "51b1c9",
Name = "Custom_Model", Name = "Custom_Model",
@ -46,14 +52,7 @@ local DAMAGE_HORROR_GUIDS = {
"468e88"; "0257d9"; "7b5729"; "beb964"; "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 TOUR_GUID = "0e5aa8"
local campaignBoxGUID local campaignBoxGUID
function onLoad(save_state) function onLoad(save_state)

View File

@ -1,3 +1,5 @@
local chaosBagApi = require("chaosbag/ChaosBagApi")
local TOKEN_IDS = { local TOKEN_IDS = {
-- first row -- first row
"p1", "0", "m1", "m2", "m3", "m4", "p1", "0", "m1", "m2", "m3", "m4",
@ -34,7 +36,6 @@ buttonParameters.height = 300
local name local name
local tokens = {} local tokens = {}
local chaosBagApi = require("chaosbag/ChaosBagApi")
function onLoad() function onLoad()
-- create buttons for tokens -- create buttons for tokens

View File

@ -2,12 +2,13 @@
- sets counters to default values (resources and doom) or trauma values (health and sanity, if not disabled) from campaign log - 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 - puts everything on playmats and hands into respective trashcans
- use the IGNORE_TAG to exclude objects from tidying (default: "CleanUpHelper_Ignore")]] - 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 blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
local chaosBagApi = require("chaosbag/ChaosBagApi") local chaosBagApi = require("chaosbag/ChaosBagApi")
local playAreaApi = require("core/PlayAreaApi") 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 -- these objects will be ignored
local IGNORE_GUIDS = { local IGNORE_GUIDS = {

View File

@ -1,5 +1,5 @@
local mythosAreaApi = require("core/MythosAreaApi")
local chaosBagApi = require("chaosbag/ChaosBagApi") local chaosBagApi = require("chaosbag/ChaosBagApi")
local mythosAreaApi = require("core/MythosAreaApi")
-- common parameters -- common parameters
local buttonParameters = {} local buttonParameters = {}

View File

@ -1,6 +1,7 @@
do do
local playAreaApi = require("core/PlayAreaApi")
local allCardsBagApi = require("playercards/AllCardsBagApi") local allCardsBagApi = require("playercards/AllCardsBagApi")
local playAreaApi = require("core/PlayAreaApi")
local ArkhamDb = { } local ArkhamDb = { }
local internal = { } local internal = { }

View File

@ -2,7 +2,6 @@ do
local DeckImporterApi = {} local DeckImporterApi = {}
local DECK_IMPORTER_GUID = "a28140" local DECK_IMPORTER_GUID = "a28140"
-- Returns a table with the full state of the UI, including options and deck IDs. -- 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 -- This can be used to persist via onSave(), or provide values for a load operation
-- Table values: -- Table values:
@ -22,7 +21,7 @@ do
end end
-- Updates the state of the UI based on the provided table. Any values not provided will be left the same. -- 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: -- Table values:
-- redDeck: Deck ID to load for the red player -- redDeck: Deck ID to load for the red player
-- orangeDeck: Deck ID to load for the orange player -- orangeDeck: Deck ID to load for the orange player

View File

@ -1,10 +1,10 @@
require("arkhamdb/DeckImporterUi") require("arkhamdb/DeckImporterUi")
require("playercards/PlayerCardSpawner") require("playercards/PlayerCardSpawner")
local playmatApi = require("playermat/PlaymatApi")
local playAreaApi = require("core/PlayAreaApi")
local allCardsBagApi = require("playercards/AllCardsBagApi") local allCardsBagApi = require("playercards/AllCardsBagApi")
local arkhamDb = require("arkhamdb/ArkhamDb") local arkhamDb = require("arkhamdb/ArkhamDb")
local playAreaApi = require("core/PlayAreaApi")
local playmatApi = require("playermat/PlaymatApi")
local zones = require("playermat/Zones") local zones = require("playermat/Zones")
function onLoad(script_state) function onLoad(script_state)

View File

@ -1,3 +1,5 @@
local allCardsBagApi = require("playercards/AllCardsBagApi")
local INPUT_FIELD_HEIGHT = 340 local INPUT_FIELD_HEIGHT = 340
local INPUT_FIELD_WIDTH = 1500 local INPUT_FIELD_WIDTH = 1500
local FIELD_COLOR = { 0.9, 0.7, 0.5 } local FIELD_COLOR = { 0.9, 0.7, 0.5 }
@ -23,8 +25,6 @@ local privateDeck = true
local loadNewestDeck = true local loadNewestDeck = true
local loadInvestigators = false local loadInvestigators = false
local allCardsBagApi = require("playercards/AllCardsBagApi")
-- Returns a table with the full state of the UI, including options and deck IDs. -- 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 -- This can be used to persist via onSave(), or provide values for a load operation
-- Table values: -- Table values:
@ -48,7 +48,7 @@ function getUiState()
end end
-- Updates the state of the UI based on the provided table. Any values not provided will be left the same. -- 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: -- Table values:
-- redDeck: Deck ID to load for the red player -- redDeck: Deck ID to load for the red player
-- orangeDeck: Deck ID to load for the orange player -- orangeDeck: Deck ID to load for the orange player

View File

@ -1,3 +1,4 @@
local chaosBagApi = require("chaosbag/ChaosBagApi")
local tokenArrangerApi = require("accessories/TokenArrangerApi") local tokenArrangerApi = require("accessories/TokenArrangerApi")
-- common button parameters -- common button parameters
@ -23,8 +24,6 @@ local FONT_COLOR = {
local whitespace = " " local whitespace = " "
local updating local updating
local chaosBagApi = require("chaosbag/ChaosBagApi")
--------------------------------------------------------- ---------------------------------------------------------
-- creating buttons and menus + initializing tables -- creating buttons and menus + initializing tables
--------------------------------------------------------- ---------------------------------------------------------

View File

@ -1,7 +1,7 @@
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
local optionPanelApi = require("core/OptionPanelApi")
local playmatApi = require("playermat/PlaymatApi") local playmatApi = require("playermat/PlaymatApi")
local victoryDisplayApi = require("core/VictoryDisplayApi") local victoryDisplayApi = require("core/VictoryDisplayApi")
local optionPanelApi = require("core/OptionPanelApi")
function onLoad() function onLoad()
addHotkey("Add Doom to Agenda", addDoomToAgenda) addHotkey("Add Doom to Agenda", addDoomToAgenda)

View File

@ -1,7 +1,7 @@
local playAreaApi = require("core/PlayAreaApi") local playAreaApi = require("core/PlayAreaApi")
local tokenArrangerApi = require("accessories/TokenArrangerApi") local tokenArrangerApi = require("accessories/TokenArrangerApi")
local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi")
local tokenChecker = require("core/token/TokenChecker") local tokenChecker = require("core/token/TokenChecker")
local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi")
local ENCOUNTER_DECK_AREA = { local ENCOUNTER_DECK_AREA = {
upperLeft = { x = 0.9, z = 0.42 }, upperLeft = { x = 0.9, z = 0.42 },

View File

@ -1,6 +1,5 @@
do do
local PlayAreaApi = { } local PlayAreaApi = { }
local PLAY_AREA_GUID = "721ba2" local PLAY_AREA_GUID = "721ba2"
local INVESTIGATOR_COUNTER_GUID = "f182ee" local INVESTIGATOR_COUNTER_GUID = "f182ee"

View File

@ -1,6 +1,7 @@
local controlActive = false
local playAreaApi = require("core/PlayAreaApi") local playAreaApi = require("core/PlayAreaApi")
local controlActive = false
-- parameters for open/close button for reusing -- parameters for open/close button for reusing
local buttonParameters = {} local buttonParameters = {}
buttonParameters.function_owner = self buttonParameters.function_owner = self

View File

@ -1,6 +1,5 @@
do do
local SoundCubeApi = {} local SoundCubeApi = {}
local internal = {}
-- this table links the name of a trigger effect to its index -- this table links the name of a trigger effect to its index
local soundIndices = { local soundIndices = {
@ -9,14 +8,14 @@ do
["Dark Souls"] = 2 ["Dark Souls"] = 2
} }
internal.playTriggerEffect = function(index) local function playTriggerEffect(index)
getObjectsWithTag("SoundCube")[1].AssetBundle.playTriggerEffect(index) getObjectsWithTag("SoundCube")[1].AssetBundle.playTriggerEffect(index)
end end
-- plays the by name requested sound -- 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) SoundCubeApi.playSoundByName = function(soundName)
internal.playTriggerEffect(soundIndices[soundName]) playTriggerEffect(soundIndices[soundName])
end end
return SoundCubeApi return SoundCubeApi

View File

@ -1,14 +1,17 @@
local chaosBagApi = require("chaosbag/ChaosBagApi")
local playAreaApi = require("core/PlayAreaApi") local playAreaApi = require("core/PlayAreaApi")
local tokenChecker = require("core/token/TokenChecker") local tokenChecker = require("core/token/TokenChecker")
local pendingCall = false local pendingCall = false
local messageSent = {} local messageSent = {}
local missingData = {} local missingData = {}
local countedVP = {} local countedVP = {}
local highlightMissing = false local highlightMissing = false
local highlightCounted = false local highlightCounted = false
local TRASHCAN local TRASHCAN
local TRASHCAN_GUID = "70b9f6" local TRASHCAN_GUID = "70b9f6"
local chaosBagApi = require("chaosbag/ChaosBagApi")
-- button creation when loading the game -- button creation when loading the game
function onLoad() function onLoad()

View File

@ -1,7 +1,7 @@
do do
local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi")
local playAreaApi = require("core/PlayAreaApi")
local optionPanelApi = require("core/OptionPanelApi") local optionPanelApi = require("core/OptionPanelApi")
local playAreaApi = require("core/PlayAreaApi")
local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi")
local PLAYER_CARD_TOKEN_OFFSETS = { local PLAYER_CARD_TOKEN_OFFSETS = {
[1] = { [1] = {

View File

@ -1,6 +1,5 @@
do do
local TokenSpawnTracker = { } local TokenSpawnTracker = { }
local SPAWN_TRACKER_GUID = "e3ffc9" local SPAWN_TRACKER_GUID = "e3ffc9"
TokenSpawnTracker.hasSpawnedTokens = function(cardGuid) TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)

View File

@ -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") require("playercards/PlayerCardSpawner")
local allCardsBagApi = require("playercards/AllCardsBagApi") local allCardsBagApi = require("playercards/AllCardsBagApi")
@ -17,9 +9,11 @@ buttonParameters.width = 1200
buttonParameters.font_size = 75 buttonParameters.font_size = 75
local BUTTON_LABELS = {} local BUTTON_LABELS = {}
BUTTON_LABELS["spawn"] = {} BUTTON_LABELS["spawn"] = {}
BUTTON_LABELS["spawn"][true] = "Mode: Spawn all matching cards " BUTTON_LABELS["spawn"][true] = "Mode: Spawn all matching cards "
BUTTON_LABELS["spawn"][false] = "Mode: Spawn first matching card" BUTTON_LABELS["spawn"][false] = "Mode: Spawn first matching card"
BUTTON_LABELS["search"] = {} BUTTON_LABELS["search"] = {}
BUTTON_LABELS["search"][true] = "Mode: Name matches search term" BUTTON_LABELS["search"][true] = "Mode: Name matches search term"
BUTTON_LABELS["search"][false] = "Mode: Name contains search term" BUTTON_LABELS["search"][false] = "Mode: Name contains search term"
@ -35,13 +29,15 @@ inputParameters.height = 130
inputParameters.font_size = 107 inputParameters.font_size = 107
-- main code -- 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) function onLoad(savedData)
local loaded_data = JSON.decode(saved_data) local loadedData = JSON.decode(savedData)
spawnAll = loaded_data[1] or false spawnAll = loadedData[1] or false
searchExact = loaded_data[2] or false searchExact = loadedData[2] or false
inputParameters.value = loaded_data[3] or "" inputParameters.value = loadedData[3] or ""
-- index 0: button for spawn mode -- index 0: button for spawn mode
buttonParameters.click_function = "search" buttonParameters.click_function = "search"
@ -62,11 +58,6 @@ function onLoad(saved_data)
self.createButton(buttonParameters) self.createButton(buttonParameters)
self.createInput(inputParameters) 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 end
function spawnMode() function spawnMode()

View File

@ -69,8 +69,9 @@ Thus it should be implemented like this:
----------------------------------------------------------]] ----------------------------------------------------------]]
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
local tokenArrangerApi = require("accessories/TokenArrangerApi")
local chaosBagApi = require("chaosbag/ChaosBagApi") local chaosBagApi = require("chaosbag/ChaosBagApi")
local tokenArrangerApi = require("accessories/TokenArrangerApi")
local sealedTokens = {} local sealedTokens = {}
local ID_URL_MAP = {} local ID_URL_MAP = {}
local tokensInBag = {} local tokensInBag = {}

View File

@ -1,7 +1,8 @@
require("playercards/PlayerCardPanelData") require("playercards/PlayerCardPanelData")
local spawnBag = require("playercards/SpawnBag")
local arkhamDb = require("arkhamdb/ArkhamDb")
local allCardsBagApi = require("playercards/AllCardsBagApi") 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 -- Size and position information for the three rows of class buttons
local CIRCLE_BUTTON_SIZE = 250 local CIRCLE_BUTTON_SIZE = 250

View File

@ -1,4 +1,3 @@
-- Amount to shift for the next card (zShift) or next row of cards (xShift) -- 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 -- Note that the table rotation is weird, and the X axis is vertical while the
-- Z axis is horizontal -- Z axis is horizontal

View File

@ -23,14 +23,14 @@ require("playercards/PlayerCardSpawner")
-- } -- }
-- See BondedBag.ttslua for an example -- See BondedBag.ttslua for an example
do do
local allCardsBagApi = require("playercards/AllCardsBagApi")
local SpawnBag = { } local SpawnBag = { }
local internal = { } local internal = { }
-- To assist debugging, will draw a box around the recall zone when it's set up -- To assist debugging, will draw a box around the recall zone when it's set up
local SHOW_RECALL_ZONE = false local SHOW_RECALL_ZONE = false
local allCardsBagApi = require("playercards/AllCardsBagApi")
-- Distance to expand the recall zone around any added object. -- Distance to expand the recall zone around any added object.
local RECALL_BUFFER_X = 0.9 local RECALL_BUFFER_X = 0.9
local RECALL_BUFFER_Z = 0.5 local RECALL_BUFFER_Z = 0.5

View File

@ -1,7 +1,3 @@
-- Stat Tracker
-- made by: Chr1Z
-- description: helps tracking the stats of your investigator
local BUTTON_PARAMETERS = {} local BUTTON_PARAMETERS = {}
BUTTON_PARAMETERS.function_owner = self BUTTON_PARAMETERS.function_owner = self
BUTTON_PARAMETERS.height = 650 BUTTON_PARAMETERS.height = 650
@ -15,52 +11,52 @@ function onSave() return JSON.encode(stats) end
-- load stats and make buttons (left to right) -- load stats and make buttons (left to right)
function onLoad(saved_data) 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 for i = 1, 4 do
BUTTON_PARAMETERS.label = stats[i] .. " " BUTTON_PARAMETERS.label = stats[i] .. " "
BUTTON_PARAMETERS.position.x = BUTTON_PARAMETERS.position.x + 1.91 BUTTON_PARAMETERS.position.x = BUTTON_PARAMETERS.position.x + 1.91
BUTTON_PARAMETERS.click_function = attachIndex("button_click", i) BUTTON_PARAMETERS.click_function = attachIndex("button_click", i)
self.createButton(BUTTON_PARAMETERS) self.createButton(BUTTON_PARAMETERS)
end 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 end
-- helper function to carry index -- helper function to carry index
function attachIndex(click_function, index) function attachIndex(click_function, index)
local fn_name = click_function .. index local fn_name = click_function .. index
_G[fn_name] = function(obj, player_color, isRightClick) _G[fn_name] = function(obj, player_color, isRightClick)
_G[click_function](obj, player_color, isRightClick, index) _G[click_function](obj, player_color, isRightClick, index)
end end
return fn_name return fn_name
end end
function button_click(_, _, isRightClick, index) function button_click(_, _, isRightClick, index)
stats[index] = math.min(math.max(stats[index] + (isRightClick and -1 or 1), 0), 99) stats[index] = math.min(math.max(stats[index] + (isRightClick and -1 or 1), 0), 99)
changeButton(index) changeButton(index)
end end
function changeButton(index) function changeButton(index)
local font_size = BUTTON_PARAMETERS.font_size local font_size = BUTTON_PARAMETERS.font_size
local whitespace = " " local whitespace = " "
if stats[index] > 9 then if stats[index] > 9 then
font_size = BUTTON_PARAMETERS.font_size * 0.65 font_size = BUTTON_PARAMETERS.font_size * 0.65
whitespace = " " whitespace = " "
end 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 end
-- formatting of "newStats": {Willpower, Intellect, Fight, Agility} -- formatting of "newStats": {Willpower, Intellect, Fight, Agility}
function updateStats(newStats) function updateStats(newStats)
if newStats and #newStats == 4 then if newStats and #newStats == 4 then
stats = newStats stats = newStats
elseif newStats then elseif newStats then
printToAll("Provided new stats are incomplete or incorrectly formatted.", "Red") printToAll("Provided new stats are incomplete or incorrectly formatted.", "Red")
return return
end end
for i = 1, 4 do changeButton(i) end for i = 1, 4 do changeButton(i) end
end end