more annotations

This commit is contained in:
Chr1Z93 2024-02-02 02:03:25 +01:00
parent bb82e6b432
commit f9faea728f
22 changed files with 104 additions and 140 deletions

View File

@ -26,26 +26,17 @@ end
function updateMemoryWithMoves() function updateMemoryWithMoves()
memoryList = memoryListBackup memoryList = memoryListBackup
--get the first transposed object's coordinates --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 -- p1 is where needs to go, p2 is where it was
local refObjPos = memoryList[moveGuid].pos local refObjPos = memoryList[moveGuid].pos
local deltaPos = findOffsetDistance(obj.getPosition(), refObjPos, nil) local deltaPos = findOffsetDistance(obj.getPosition(), refObjPos, nil)
local movedRotation = obj.getRotation()
for guid, entry in pairs(memoryList) do for guid, entry in pairs(memoryList) do
memoryList[guid].pos.x = entry.pos.x - deltaPos.x memoryList[guid].pos.x = entry.pos.x - deltaPos.x
memoryList[guid].pos.y = entry.pos.y - deltaPos.y memoryList[guid].pos.y = entry.pos.y - deltaPos.y
memoryList[guid].pos.z = entry.pos.z - deltaPos.z 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 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 = {} moveList = {}
end end

View File

@ -26,26 +26,17 @@ end
function updateMemoryWithMoves() function updateMemoryWithMoves()
memoryList = memoryListBackup memoryList = memoryListBackup
--get the first transposed object's coordinates --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 -- p1 is where needs to go, p2 is where it was
local refObjPos = memoryList[moveGuid].pos local refObjPos = memoryList[moveGuid].pos
local deltaPos = findOffsetDistance(obj.getPosition(), refObjPos, nil) local deltaPos = findOffsetDistance(obj.getPosition(), refObjPos, nil)
local movedRotation = obj.getRotation()
for guid, entry in pairs(memoryList) do for guid, entry in pairs(memoryList) do
memoryList[guid].pos.x = entry.pos.x - deltaPos.x memoryList[guid].pos.x = entry.pos.x - deltaPos.x
memoryList[guid].pos.y = entry.pos.y - deltaPos.y memoryList[guid].pos.y = entry.pos.y - deltaPos.y
memoryList[guid].pos.z = entry.pos.z - deltaPos.z 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 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 = {} moveList = {}
end end

View File

@ -243,26 +243,17 @@ end
function updateMemoryWithMoves() function updateMemoryWithMoves()
memoryList = memoryListBackup memoryList = memoryListBackup
--get the first transposed object's coordinates --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 -- p1 is where needs to go, p2 is where it was
local refObjPos = memoryList[moveGuid].pos local refObjPos = memoryList[moveGuid].pos
local deltaPos = findOffsetDistance(obj.getPosition(), refObjPos, nil) local deltaPos = findOffsetDistance(obj.getPosition(), refObjPos, nil)
local movedRotation = obj.getRotation()
for guid, entry in pairs(memoryList) do for guid, entry in pairs(memoryList) do
memoryList[guid].pos.x = entry.pos.x - deltaPos.x memoryList[guid].pos.x = entry.pos.x - deltaPos.x
memoryList[guid].pos.y = entry.pos.y - deltaPos.y memoryList[guid].pos.y = entry.pos.y - deltaPos.y
memoryList[guid].pos.z = entry.pos.z - deltaPos.z 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 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 = {} moveList = {}
end end
@ -809,4 +800,3 @@ end
function AllMemoryBagsInScene:getGuidList() function AllMemoryBagsInScene:getGuidList()
return Global.getTable(self.NAME_OF_GLOBAL_VARIABLE) or {} return Global.getTable(self.NAME_OF_GLOBAL_VARIABLE) or {}
end end

View File

@ -63,8 +63,11 @@ do
return false, "Indexing not complete" return false, "Indexing not complete"
end end
local deckUri = { configuration.api_uri, local deckUri = {
isPrivate and configuration.private_deck or configuration.public_deck, deckId } configuration.api_uri,
isPrivate and configuration.private_deck or configuration.public_deck,
deckId
}
local deck = Request.start(deckUri, function(status) local deck = Request.start(deckUri, function(status)
if string.find(status.text, "<!DOCTYPE html>") then if string.find(status.text, "<!DOCTYPE html>") then
@ -408,9 +411,9 @@ do
is_successful = false is_successful = false
} }
-- Creates a new instance of a Request. Should not be directly called. Instead use Request.start and Request.deferred. -- Creates a new instance of a Request. Should not be directly called. Instead use Request.start() and Request.deferred().
---@param uri string ---@param uri table
---@param configure fun(request: Request, status: WebRequestStatus) ---@param configure fun(request, status)
---@return Request ---@return Request
function Request:new(uri, configure) function Request:new(uri, configure)
local this = {} local this = {}
@ -431,9 +434,8 @@ do
-- Creates a new request. on_success should set the request's is_done, is_successful, and content variables. -- 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) -- 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 table ---@param uri table
---@param on_success fun(request: Request, status: WebRequestStatus, vararg: any) ---@param on_success fun(request, status, vararg)
---@param on_error fun(status: WebRequestStatus)|nil ---@param on_error fun(status)|nil
---@vararg any[]
---@return Request ---@return Request
function Request.deferred(uri, on_success, on_error, ...) function Request.deferred(uri, on_success, on_error, ...)
local parameters = table.pack(...) local parameters = table.pack(...)
@ -450,10 +452,10 @@ do
end) end)
end end
-- Creates a new request. on_success should return weather the resultant data is as expected, and the processed content of the request. -- 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 uri table
---@param on_success fun(status: WebRequestStatus, vararg: any): boolean, any ---@param on_success fun(status, vararg): boolean, any
---@param on_error nil|fun(status: WebRequestStatus, vararg: any): string ---@param on_error nil|fun(status, vararg): string
---@vararg any ---@vararg any
---@return Request ---@return Request
function Request.start(uri, on_success, on_error, ...) function Request.start(uri, on_success, on_error, ...)

View File

@ -6,16 +6,18 @@ do
return guidReferenceApi.getObjectByOwnerAndType("Mythos", "DeckImporter") return guidReferenceApi.getObjectByOwnerAndType("Mythos", "DeckImporter")
end 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. -- 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: ---@return uiStateTable uiStateTable Contains data about the current UI state
-- 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
DeckImporterApi.getUiState = function() DeckImporterApi.getUiState = function()
local passthroughTable = {} local passthroughTable = {}
for k,v in pairs(getDeckImporter().call("getUiState")) do for k,v in pairs(getDeckImporter().call("getUiState")) do
@ -25,15 +27,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 Table of values to update on importer ---@return uiStateTable uiStateTable Contains data about the current UI state
-- 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
DeckImporterApi.setUiState = function(uiStateTable) DeckImporterApi.setUiState = function(uiStateTable)
return getDeckImporter().call("setUiState", uiStateTable) return getDeckImporter().call("setUiState", uiStateTable)
end end

View File

@ -59,7 +59,7 @@ function buildDeck(playerColor, deckId)
arkhamDb.getDecklist( arkhamDb.getDecklist(
playerColor, playerColor,
deckId, deckId,
uiState.private, uiState.privateDeck,
uiState.loadNewest, uiState.loadNewest,
uiState.investigators, uiState.investigators,
loadCards) loadCards)

View File

@ -27,21 +27,14 @@ local loadInvestigators = false
-- 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: ---@return uiStateTable uiStateTable Contains data about the current UI state
-- 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
function getUiState() function getUiState()
return { return {
redDeck = redDeckId, redDeck = redDeckId,
orangeDeck = orangeDeckId, orangeDeck = orangeDeckId,
whiteDeck = whiteDeckId, whiteDeck = whiteDeckId,
greenDeck = greenDeckId, greenDeck = greenDeckId,
private = privateDeck, privateDeck = privateDeck,
loadNewest = loadNewestDeck, loadNewest = loadNewestDeck,
investigators = loadInvestigators investigators = loadInvestigators
} }
@ -49,14 +42,6 @@ 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 Table of values to update on importer ---@param uiStateTable table 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
function setUiState(uiStateTable) function setUiState(uiStateTable)
self.clearButtons() self.clearButtons()
self.clearInputs() self.clearInputs()
@ -70,7 +55,7 @@ function initializeUi(savedUiState)
orangeDeckId = savedUiState.orangeDeck orangeDeckId = savedUiState.orangeDeck
whiteDeckId = savedUiState.whiteDeck whiteDeckId = savedUiState.whiteDeck
greenDeckId = savedUiState.greenDeck greenDeckId = savedUiState.greenDeck
privateDeck = savedUiState.private privateDeck = savedUiState.privateDeck
loadNewestDeck = savedUiState.loadNewest loadNewestDeck = savedUiState.loadNewest
loadInvestigators = savedUiState.investigators loadInvestigators = savedUiState.investigators
end end

View File

@ -63,7 +63,6 @@ function initializeState()
-- count tokens in the bag -- count tokens in the bag
local chaosBag = chaosBagApi.findChaosBag() local chaosBag = chaosBagApi.findChaosBag()
local tokens = {}
for _, v in ipairs(chaosBag.getObjects()) do for _, v in ipairs(chaosBag.getObjects()) do
if v.name == "Bless" then if v.name == "Bless" then
numInPlay.Bless = numInPlay.Bless + 1 numInPlay.Bless = numInPlay.Bless + 1
@ -207,7 +206,7 @@ end
--------------------------------------------------------- ---------------------------------------------------------
-- returns a formatted string with information about the provided token type (bless / curse) -- returns a formatted string with information about the provided token type (bless / curse)
---@param type string "Bless" or "Curse" ---@param type string Type of chaos token ("Bless" or "Curse")
---@param omitBrackets? boolean Controls whether the brackets should be omitted from the return ---@param omitBrackets? boolean Controls whether the brackets should be omitted from the return
---@return string tokenCount ---@return string tokenCount
function formatTokenCount(type, omitBrackets) function formatTokenCount(type, omitBrackets)

View File

@ -15,16 +15,22 @@ do
end end
-- updates the internal count (called by cards that seal bless/curse tokens) -- 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) BlessCurseManagerApi.sealedToken = function(type, guid)
getManager().call("sealedToken", { type = type, guid = guid }) getManager().call("sealedToken", { type = type, guid = guid })
end end
-- updates the internal count (called by cards that seal bless/curse tokens) -- 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) BlessCurseManagerApi.releasedToken = function(type, guid)
getManager().call("releasedToken", { type = type, guid = guid }) getManager().call("releasedToken", { type = type, guid = guid })
end end
-- updates the internal count (called by cards that seal bless/curse tokens) -- 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) BlessCurseManagerApi.returnedToken = function(type, guid)
getManager().call("returnedToken", { type = type, guid = guid }) getManager().call("returnedToken", { type = type, guid = guid })
end end

View File

@ -29,13 +29,14 @@ do
end end
-- returns all sealed tokens on cards to the chaos bag -- 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) ChaosBagApi.releaseAllSealedTokens = function(playerColor)
return Global.call("releaseAllSealedTokens", playerColor) return Global.call("releaseAllSealedTokens", playerColor)
end end
-- returns all drawn tokens to the chaos bag -- returns all drawn tokens to the chaos bag
ChaosBagApi.returnChaosTokens = function(playerColor) ChaosBagApi.returnChaosTokens = function()
return Global.call("returnChaosTokens", playerColor) return Global.call("returnChaosTokens")
end end
-- removes the specified chaos token from the chaos bag -- removes the specified chaos token from the chaos bag
@ -45,7 +46,7 @@ do
end end
-- returns a chaos token to the bag and calls all relevant functions -- returns a chaos token to the bag and calls all relevant functions
---@param token tts__GameObject Chaos Token to return ---@param token tts__GameObject Chaos token to return
ChaosBagApi.returnChaosTokenToBag = function(token) ChaosBagApi.returnChaosTokenToBag = function(token)
return Global.call("returnChaosTokenToBag", token) return Global.call("returnChaosTokenToBag", token)
end end
@ -66,6 +67,8 @@ do
end end
-- called by playermats (by the "Draw chaos token" button) -- called by playermats (by the "Draw chaos token" button)
---@param mat tts__GameObject Playermat that triggered this
---@param drawAdditional boolean Controls whether additional tokens should be drawn
ChaosBagApi.drawChaosToken = function(mat, drawAdditional) ChaosBagApi.drawChaosToken = function(mat, drawAdditional)
return Global.call("drawChaosToken", {mat = mat, drawAdditional = drawAdditional}) return Global.call("drawChaosToken", {mat = mat, drawAdditional = drawAdditional})
end end

View File

@ -5,21 +5,23 @@ do
return getObjectFromGUID("123456") return getObjectFromGUID("123456")
end 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
---@param type string Type of object to search for ---@param type string Type of object to search for
---@return any: Object reference to the matching object
GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type) GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)
return getGuidHandler().call("getObjectByOwnerAndType", { owner = owner, type = type }) return getGuidHandler().call("getObjectByOwnerAndType", { owner = owner, type = type })
end end
-- returns all matching objects as a table with references -- 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) GUIDReferenceApi.getObjectsByType = function(type)
return getGuidHandler().call("getObjectsByType", type) return getGuidHandler().call("getObjectsByType", type)
end end
-- returns all matching objects as a table with references -- 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) GUIDReferenceApi.getObjectsByOwner = function(owner)
return getGuidHandler().call("getObjectsByOwner", owner) return getGuidHandler().call("getObjectsByOwner", owner)
end end

View File

@ -1291,7 +1291,7 @@ end
-- handles the applying of option selections and calls the respective functions based -- 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 id string ID of the option that was selected or deselected
---@param state boolean State of the option (true = enabled) ---@param state boolean|any State of the option (true = enabled)
function applyOptionPanelChange(id, state) function applyOptionPanelChange(id, state)
-- option: Snap tags -- option: Snap tags
if id == "useSnapTags" then if id == "useSnapTags" then
@ -1397,8 +1397,8 @@ end
-- copies the specified tool (by name) from the option panel source bag -- copies the specified tool (by name) from the option panel source bag
---@param name string Name of the object that should be copied ---@param name string Name of the object that should be copied
---@param position table Desired position of the object ---@param position tts__Vector Desired position of the object
---@param rotation table Desired rotation of the object (defaults to object's rotation) ---@param rotation? tts__Vector Desired rotation of the object (defaults to object's rotation)
function spawnHelperObject(name, position, rotation) function spawnHelperObject(name, position, rotation)
local sourceBag = guidReferenceApi.getObjectByOwnerAndType("Mythos","OptionPanelSource") local sourceBag = guidReferenceApi.getObjectByOwnerAndType("Mythos","OptionPanelSource")
@ -1457,6 +1457,8 @@ end
-- loads saved options -- loads saved options
function loadSettings(newOptions) 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 optionPanel = newOptions
updateOptionPanelState() updateOptionPanelState()
for id, state in pairs(optionPanel) do for id, state in pairs(optionPanel) do

View File

@ -6,17 +6,19 @@ do
return guidReferenceApi.getObjectByOwnerAndType("Mythos", "MythosArea") return guidReferenceApi.getObjectByOwnerAndType("Mythos", "MythosArea")
end 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() MythosAreaApi.returnTokenData = function()
return getMythosArea().call("returnTokenData") return getMythosArea().call("returnTokenData")
end end
-- returns an object reference to the encounter deck ---@return any: Object reference to the encounter deck
MythosAreaApi.getEncounterDeck = function() MythosAreaApi.getEncounterDeck = function()
return getMythosArea().call("getEncounterDeck") return getMythosArea().call("getEncounterDeck")
end end
-- draw an encounter card for the requesting mat -- draw an encounter card for the requesting mat
---@param mat tts__GameObject Playermat that triggered this
---@param alwaysFaceUp boolean Whether the card should be drawn face-up
MythosAreaApi.drawEncounterCard = function(mat, alwaysFaceUp) MythosAreaApi.drawEncounterCard = function(mat, alwaysFaceUp)
getMythosArea().call("drawEncounterCard", {mat = mat, alwaysFaceUp = alwaysFaceUp}) getMythosArea().call("drawEncounterCard", {mat = mat, alwaysFaceUp = alwaysFaceUp})
end end

View File

@ -6,7 +6,7 @@ do
return guidReferenceApi.getObjectByOwnerAndType("Mythos", "NavigationOverlayHandler") return guidReferenceApi.getObjectByOwnerAndType("Mythos", "NavigationOverlayHandler")
end end
-- Copies the visibility for the Navigation overlay -- copies the visibility for the Navigation overlay
---@param startColor string Color of the player to copy from ---@param startColor string Color of the player to copy from
---@param targetColor string Color of the targeted player ---@param targetColor string Color of the targeted player
NavigationOverlayApi.copyVisibility = function(startColor, targetColor) NavigationOverlayApi.copyVisibility = function(startColor, targetColor)
@ -16,7 +16,7 @@ do
}) })
end end
-- Changes the Navigation Overlay view ("Full View" --> "Play Areas" --> "Closed" etc.) -- changes the Navigation Overlay view ("Full View" --> "Play Areas" --> "Closed" etc.)
---@param playerColor string Color of the player to update the visibility for ---@param playerColor string Color of the player to update the visibility for
NavigationOverlayApi.cycleVisibility = function(playerColor) NavigationOverlayApi.cycleVisibility = function(playerColor)
getNOHandler().call("cycleVisibility", playerColor) getNOHandler().call("cycleVisibility", playerColor)

View File

@ -236,7 +236,7 @@ end
-- handles all button clicks -- handles all button clicks
function buttonClicked(player, _, id) function buttonClicked(player, _, id)
local index = tonumber(id) local index = tonumber(id) or ""
if index == 19 then if index == 19 then
setVisibility("toggle", player.color) setVisibility("toggle", player.color)

View File

@ -2,12 +2,12 @@ do
local OptionPanelApi = {} local OptionPanelApi = {}
-- loads saved options -- loads saved options
---@param options table New options table ---@param options table Set a new state for the option table
OptionPanelApi.loadSettings = function(options) OptionPanelApi.loadSettings = function(options)
return Global.call("loadSettings", options) return Global.call("loadSettings", options)
end end
-- returns option panel table ---@return any: Table of option panel state
OptionPanelApi.getOptions = function() OptionPanelApi.getOptions = function()
return Global.getTable("optionPanel") return Global.getTable("optionPanel")
end end

View File

@ -125,7 +125,7 @@ function onCollisionEnter(collisionInfo)
-- If this card was being dragged, clear the dragging connections. A multi-drag/drop may send -- 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 -- the dropped card immediately into a deck, so this has to be done here
if draggingGuids[card.getGUID()] ~= nil then if draggingGuids[card.getGUID()] ~= nil then
card.setVectorLines(nil) card.setVectorLines({})
draggingGuids[card.getGUID()] = nil draggingGuids[card.getGUID()] = nil
end end
@ -197,7 +197,7 @@ function onUpdate()
-- If object still exists then it's been dragged outside the area and needs to clear the -- If object still exists then it's been dragged outside the area and needs to clear the
-- lines attached to it -- lines attached to it
if obj ~= nil then if obj ~= nil then
obj.setVectorLines(nil) obj.setVectorLines({})
end end
end end
-- Even if the last location left the play area, need one last draw to clear the lines -- Even if the last location left the play area, need one last draw to clear the lines
@ -257,11 +257,11 @@ end
-- Global event handler, delegated from Global. Clears any connection lines from dragged cards -- 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 -- before they are destroyed by entering a deck. Removal of the card from the dragging list will
-- be handled during the next onUpdate() call. -- be handled during the next onUpdate() call.
function tryObjectEnterContainer(params) function tryObjectEnterContainer()
for draggedGuid, _ in pairs(draggingGuids) do for draggedGuid, _ in pairs(draggingGuids) do
local draggedObj = getObjectFromGUID(draggedGuid) local draggedObj = getObjectFromGUID(draggedGuid)
if draggedObj ~= nil then if draggedObj ~= nil then
draggedObj.setVectorLines(nil) draggedObj.setVectorLines({})
end end
end end
end end
@ -451,13 +451,11 @@ function addOneWayVector(origin, target, vectorOwner, lines)
-- Calculate card distance to be closer for horizontal positions than vertical, since cards are -- Calculate card distance to be closer for horizontal positions than vertical, since cards are
-- taller than they are wide -- taller than they are wide
local heading = Vector(originPos):sub(targetPos):heading("y") local heading = Vector(originPos):sub(targetPos):heading("y")
local distanceFromCard = DIRECTIONAL_ARROW_DISTANCE * 0.7 + local distanceFromCard = DIRECTIONAL_ARROW_DISTANCE * 0.7 + DIRECTIONAL_ARROW_DISTANCE * 0.3 * math.abs(math.sin(math.rad(heading)))
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 -- 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 -- 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, local midpoint = Vector(originPos):add(targetPos):scale(0.5):moveTowards(targetPos, ARROW_ARM_LENGTH / 2)
ARROW_ARM_LENGTH / 2)
local closeToOrigin = Vector(originPos):moveTowards(targetPos, distanceFromCard + 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) local closeToTarget = Vector(targetPos):moveTowards(originPos, distanceFromCard - ARROW_ARM_LENGTH / 2)
@ -470,16 +468,14 @@ function addOneWayVector(origin, target, vectorOwner, lines)
end end
-- Draws an arrowhead at the given position. -- Draws an arrowhead at the given position.
---@param arrowheadPos table Centerpoint of the arrowhead to draw (NOT the tip of the arrow) ---@param arrowheadPos tts__Vector 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 originPos tts__Vector Origin point of the connection, used to position the arrow arms
---@param vectorOwner tts__GameObject The object which these lines will be set to. Used for relative ---@param vectorOwner tts__GameObject The object which these lines will be set to. Used for relative
--- positioning and scaling, as well as highlighting connections during a drag operation --- 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) function addArrowLines(arrowheadPos, originPos, vectorOwner, lines)
local arrowArm1 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver("y", local arrowArm1 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver("y", -1 * ARROW_ANGLE):add(arrowheadPos)
-1 * ARROW_ANGLE):add(arrowheadPos) local arrowArm2 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver("y", 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 head = vectorOwner.positionToLocal(arrowheadPos)
local arm1 = vectorOwner.positionToLocal(arrowArm1) local arm1 = vectorOwner.positionToLocal(arrowArm1)

View File

@ -26,37 +26,37 @@ do
-- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded' -- 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 for messages ---@param playerColor string Color of the player requesting the shift for messages
PlayAreaApi.shiftContentsUp = function(playerColor) PlayAreaApi.shiftContentsUp = function(playerColor)
return getPlayArea().call("shiftContentsUp", playerColor) getPlayArea().call("shiftContentsUp", playerColor)
end end
PlayAreaApi.shiftContentsDown = function(playerColor) PlayAreaApi.shiftContentsDown = function(playerColor)
return getPlayArea().call("shiftContentsDown", playerColor) getPlayArea().call("shiftContentsDown", playerColor)
end end
PlayAreaApi.shiftContentsLeft = function(playerColor) PlayAreaApi.shiftContentsLeft = function(playerColor)
return getPlayArea().call("shiftContentsLeft", playerColor) getPlayArea().call("shiftContentsLeft", playerColor)
end end
PlayAreaApi.shiftContentsRight = function(playerColor) PlayAreaApi.shiftContentsRight = function(playerColor)
return getPlayArea().call("shiftContentsRight", playerColor) getPlayArea().call("shiftContentsRight", playerColor)
end end
-- Reset the play area's tracking of which cards have had tokens spawned. -- Reset the play area's tracking of which cards have had tokens spawned.
PlayAreaApi.resetSpawnedCards = function() PlayAreaApi.resetSpawnedCards = function()
return getPlayArea().call("resetSpawnedCards") getPlayArea().call("resetSpawnedCards")
end end
-- Sets whether location connections should be drawn ---@param state boolean This controls whether location connections should be drawn
PlayAreaApi.setConnectionDrawState = function(state) PlayAreaApi.setConnectionDrawState = function(state)
getPlayArea().call("setConnectionDrawState", state) getPlayArea().call("setConnectionDrawState", state)
end end
-- Sets the connection color ---@param color string Connection color to be used for location connections
PlayAreaApi.setConnectionColor = function(color) PlayAreaApi.setConnectionColor = function(color)
getPlayArea().call("setConnectionColor", color) getPlayArea().call("setConnectionColor", color)
end end
-- Event to be called when the current scenario has changed. -- Event to be called when the current scenario has changed
---@param scenarioName string Name of the new scenario ---@param scenarioName string Name of the new scenario
PlayAreaApi.onScenarioChanged = function(scenarioName) PlayAreaApi.onScenarioChanged = function(scenarioName)
getPlayArea().call("onScenarioChanged", scenarioName) getPlayArea().call("onScenarioChanged", scenarioName)
@ -64,7 +64,7 @@ do
-- Sets this playmat's snap points to limit snapping to locations or not. -- 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. -- 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) PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)
getPlayArea().call("setLimitSnapsByType", matchCardTypes) getPlayArea().call("setLimitSnapsByType", matchCardTypes)
end end

View File

@ -9,6 +9,7 @@ do
["Dark Souls"] = 2 ["Dark Souls"] = 2
} }
---@param index number Index of the sound effect to play
local function playTriggerEffect(index) local function playTriggerEffect(index)
local SoundCube = guidReferenceApi.getObjectByOwnerAndType("Mythos", "SoundCube") local SoundCube = guidReferenceApi.getObjectByOwnerAndType("Mythos", "SoundCube")
SoundCube.AssetBundle.playTriggerEffect(index) SoundCube.AssetBundle.playTriggerEffect(index)

View File

@ -6,7 +6,7 @@ do
return guidReferenceApi.getObjectByOwnerAndType("Mythos", "VictoryDisplay") return guidReferenceApi.getObjectByOwnerAndType("Mythos", "VictoryDisplay")
end end
-- triggers an update of the Victory count -- triggers an update of the victory count
---@param delay number Delay in seconds after which the update call is executed ---@param delay number Delay in seconds after which the update call is executed
VictoryDisplayApi.update = function(delay) VictoryDisplayApi.update = function(delay)
getVictoryDisplay().call("startUpdate", delay) getVictoryDisplay().call("startUpdate", delay)

View File

@ -1,3 +1,4 @@
---@diagnostic disable: param-type-mismatch
require("playercards/PlayerCardPanelData") require("playercards/PlayerCardPanelData")
local allCardsBagApi = require("playercards/AllCardsBagApi") local allCardsBagApi = require("playercards/AllCardsBagApi")
@ -400,8 +401,7 @@ function scalePositions()
startPositions = { } startPositions = { }
for key, pos in pairs(START_POSITIONS) do for key, pos in pairs(START_POSITIONS) do
-- Because a scaled object means a different global size, using global distance for Z results in -- 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 -- the cards being closer or farther depending on the scale. Leave the Z values and only scale X and Y
-- X and Y
startPositions[key] = Vector(pos) startPositions[key] = Vector(pos)
startPositions[key].x = startPositions[key].x * scale startPositions[key].x = startPositions[key].x * scale
startPositions[key].y = startPositions[key].y * scale startPositions[key].y = startPositions[key].y * scale
@ -517,7 +517,7 @@ function buildCommonSpawnSpec(investigatorName, investigatorData, position, oneC
cards = oneCardOnly and { investigatorData.cards[1] } or investigatorData.cards, cards = oneCardOnly and { investigatorData.cards[1] } or investigatorData.cards,
globalPos = self.positionToWorld(cardPos), globalPos = self.positionToWorld(cardPos),
rotation = FACE_UP_ROTATION, rotation = FACE_UP_ROTATION,
}, }
} }
end end

View File

@ -219,7 +219,7 @@ function updateTextField(rowIndex)
end end
end end
function clickCheckbox(row, col, buttonIndex) function clickCheckbox(row, col)
if selectedUpgrades[row] == nil then if selectedUpgrades[row] == nil then
selectedUpgrades[row] = { } selectedUpgrades[row] = { }
selectedUpgrades[row].xp = 0 selectedUpgrades[row].xp = 0