more dynamic references
This commit is contained in:
parent
889f0af13f
commit
c11ef5daba
@ -101,7 +101,7 @@
|
||||
"ClueCounter.d86b7c",
|
||||
"MasterClueCounter.4a3aa4",
|
||||
"LegacyAssets.7165a9",
|
||||
"Playarea.721ba2",
|
||||
"PlayArea.721ba2",
|
||||
"BarkhamHorror.308439",
|
||||
"ScriptingTrigger.fb28e1",
|
||||
"ScriptingTrigger.7af2cf",
|
||||
|
@ -72,10 +72,6 @@
|
||||
"displayed": "LargeBox",
|
||||
"normalized": "largebox"
|
||||
},
|
||||
{
|
||||
"displayed": "SoundCube",
|
||||
"normalized": "soundcube"
|
||||
},
|
||||
{
|
||||
"displayed": "CampaignBox",
|
||||
"normalized": "campaignbox"
|
||||
|
@ -1575,6 +1575,7 @@
|
||||
"LuaScriptState": "",
|
||||
"MaterialIndex": -1,
|
||||
"MeasureMovement": false,
|
||||
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"AllCardsBag\"}",
|
||||
"MeshIndex": -1,
|
||||
"Name": "Bag",
|
||||
"Nickname": "All Player Cards",
|
||||
|
@ -36,6 +36,7 @@
|
||||
"LuaScript": "require(\"arkhamdb/DeckImporterMain\")",
|
||||
"LuaScriptState_path": "ArkhamDBDeckImporter.a28140.luascriptstate",
|
||||
"MeasureMovement": false,
|
||||
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"DeckImporter\"}",
|
||||
"Name": "Custom_Tile",
|
||||
"Nickname": "ArkhamDB Deck Importer",
|
||||
"Snap": false,
|
||||
|
@ -36,6 +36,7 @@
|
||||
"LuaScript": "require(\"core/ActiveInvestigatorCounter\")",
|
||||
"LuaScriptState": "2",
|
||||
"MeasureMovement": false,
|
||||
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"InvestigatorCounter\"}",
|
||||
"Name": "Custom_Token",
|
||||
"Nickname": "Investigator Count",
|
||||
"Snap": true,
|
||||
|
@ -24,6 +24,7 @@
|
||||
"LuaScript": "require(\"core/NavigationOverlayHandler\")",
|
||||
"LuaScriptState_path": "NavigationOverlayHandler.797ede.luascriptstate",
|
||||
"MeasureMovement": false,
|
||||
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"NavigationOverlayHandler\"}",
|
||||
"Name": "go_game_piece_black",
|
||||
"Nickname": "Navigation Overlay Handler",
|
||||
"Snap": true,
|
||||
|
@ -975,7 +975,7 @@
|
||||
"MeasureMovement": false,
|
||||
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"PlayArea\"}",
|
||||
"Name": "Custom_Token",
|
||||
"Nickname": "Playarea",
|
||||
"Nickname": "Play Area",
|
||||
"Snap": true,
|
||||
"Sticky": true,
|
||||
"Tags": [
|
||||
|
@ -31,13 +31,11 @@
|
||||
"LuaScript": "",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"SoundCube\"}",
|
||||
"Name": "Custom_Assetbundle",
|
||||
"Nickname": "SoundCube",
|
||||
"Snap": true,
|
||||
"Sticky": true,
|
||||
"Tags": [
|
||||
"SoundCube"
|
||||
],
|
||||
"Tooltip": true,
|
||||
"Transform": {
|
||||
"posX": 78,
|
||||
|
@ -1,32 +1,11 @@
|
||||
do
|
||||
local TokenArrangerApi = {}
|
||||
|
||||
-- gets the first object that matches the provided information
|
||||
---@param matColor String Color of the playermat
|
||||
---@param type String Object to look for (usually name without spaces)
|
||||
local function getObjectFromMemo(matColor, type)
|
||||
if matColor == nil or type == nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
for _, obj in ipairs(getObjects()) do
|
||||
local memo = obj.getMemo()
|
||||
if memo then
|
||||
local decoded = JSON.decode(memo) or {}
|
||||
if decoded.matColor == matColor and decoded.type == type then
|
||||
return obj
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- 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
|
||||
local function callIfExistent(functionName, argument)
|
||||
local tokenArranger = getObjectFromMemo("Mythos", "TokenArranger")
|
||||
local tokenArranger = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "TokenArranger"})
|
||||
if tokenArranger ~= nil then
|
||||
tokenArranger.call(functionName, argument)
|
||||
end
|
||||
|
@ -1,6 +1,5 @@
|
||||
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
|
||||
@ -14,7 +13,8 @@ do
|
||||
-- investigators: True if investigator cards should be spawned
|
||||
DeckImporterApi.getUiState = function()
|
||||
local passthroughTable = {}
|
||||
for k,v in pairs(getObjectFromGUID(DECK_IMPORTER_GUID).call("getUiState")) do
|
||||
local DeckImporter = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DeckImporter"})
|
||||
for k,v in pairs(DeckImporter.call("getUiState")) do
|
||||
passthroughTable[k] = v
|
||||
end
|
||||
return passthroughTable
|
||||
@ -31,7 +31,8 @@ do
|
||||
-- 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)
|
||||
return getObjectFromGUID(DECK_IMPORTER_GUID).call("setUiState", uiStateTable)
|
||||
local DeckImporter = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DeckImporter"})
|
||||
return DeckImporter.call("setUiState", uiStateTable)
|
||||
end
|
||||
|
||||
return DeckImporterApi
|
||||
|
@ -1,30 +1,9 @@
|
||||
do
|
||||
local BlessCurseManagerApi = {}
|
||||
|
||||
-- gets the first object that matches the provided information
|
||||
---@param matColor String Color of the playermat
|
||||
---@param type String Object to look for (usually name without spaces)
|
||||
local function getObjectFromMemo(matColor, type)
|
||||
if matColor == nil or type == nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
for _, obj in ipairs(getObjects()) do
|
||||
local memo = obj.getMemo()
|
||||
if memo then
|
||||
local decoded = JSON.decode(memo) or {}
|
||||
if decoded.matColor == matColor and decoded.type == type then
|
||||
return obj
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- removes all taken tokens and resets the counts
|
||||
BlessCurseManagerApi.removeTakenTokensAndReset = function()
|
||||
local BlessCurseManager = getObjectFromMemo("Mythos", "BlessCurseManager")
|
||||
local BlessCurseManager = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "BlessCurseManager"})
|
||||
Wait.time(function() BlessCurseManager.call("removeTakenTokens", "Bless") end, 0.05)
|
||||
Wait.time(function() BlessCurseManager.call("removeTakenTokens", "Curse") end, 0.10)
|
||||
Wait.time(function() BlessCurseManager.call("doReset", "White") end, 0.15)
|
||||
@ -32,30 +11,35 @@ do
|
||||
|
||||
-- updates the internal count (called by cards that seal bless/curse tokens)
|
||||
BlessCurseManagerApi.sealedToken = function(type, guid)
|
||||
getObjectFromMemo("Mythos", "BlessCurseManager").call("sealedToken", { type = type, guid = guid })
|
||||
local BlessCurseManager = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "BlessCurseManager"})
|
||||
BlessCurseManager.call("sealedToken", { type = type, guid = guid })
|
||||
end
|
||||
|
||||
-- updates the internal count (called by cards that seal bless/curse tokens)
|
||||
BlessCurseManagerApi.releasedToken = function(type, guid)
|
||||
getObjectFromMemo("Mythos", "BlessCurseManager").call("releasedToken", { type = type, guid = guid })
|
||||
local BlessCurseManager = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "BlessCurseManager"})
|
||||
BlessCurseManager.call("releasedToken", { 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
|
||||
BlessCurseManagerApi.broadcastStatus = function(playerColor)
|
||||
getObjectFromMemo("Mythos", "BlessCurseManager").call("broadcastStatus", playerColor)
|
||||
local BlessCurseManager = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "BlessCurseManager"})
|
||||
BlessCurseManager.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
|
||||
BlessCurseManagerApi.removeAll = function(playerColor)
|
||||
getObjectFromMemo("Mythos", "BlessCurseManager").call("doRemove", playerColor)
|
||||
local BlessCurseManager = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "BlessCurseManager"})
|
||||
BlessCurseManager.call("doRemove", playerColor)
|
||||
end
|
||||
|
||||
-- adds Wendy's menu to the hovered card (allows sealing of tokens)
|
||||
---@param color String Color of the player to show the broadcast to
|
||||
BlessCurseManagerApi.addWendysMenu = function(playerColor, hoveredObject)
|
||||
getObjectFromMemo("Mythos", "BlessCurseManager").call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject })
|
||||
local BlessCurseManager = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "BlessCurseManager"})
|
||||
BlessCurseManager.call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject })
|
||||
end
|
||||
|
||||
return BlessCurseManagerApi
|
||||
|
@ -170,6 +170,57 @@ function tryObjectEnterContainer(container, object)
|
||||
return true
|
||||
end
|
||||
|
||||
-- gets the first object that matches the provided information
|
||||
---@param searchParam Table Contains matColor and type to search for
|
||||
function getObjectFromMemo(searchParam)
|
||||
local matColor = searchParam.matColor
|
||||
local type = searchParam.type
|
||||
if matColor == nil or type == nil then return nil end
|
||||
for _, obj in ipairs(getObjects()) do
|
||||
local memo = obj.getMemo()
|
||||
if memo then
|
||||
local decoded = JSON.decode(memo) or {}
|
||||
if decoded.matColor == matColor and decoded.type == type then
|
||||
return obj
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- gets all objects that match the provided matcolor
|
||||
---@param matColor String Color of the playermat
|
||||
function getObjectsForMatColor(matColor)
|
||||
if matColor == nil then return nil end
|
||||
local objList = {}
|
||||
for _, obj in ipairs(getObjects()) do
|
||||
local memo = obj.getMemo()
|
||||
if memo then
|
||||
local decoded = JSON.decode(memo) or {}
|
||||
if decoded.matColor == matColor then
|
||||
table.insert(objList, obj)
|
||||
end
|
||||
end
|
||||
end
|
||||
return objList
|
||||
end
|
||||
|
||||
-- gets all objects that match the provided type
|
||||
---@param type String Object to look for (usually name without spaces)
|
||||
function getObjectForType(type)
|
||||
if type == nil then return nil end
|
||||
for _, obj in ipairs(getObjects()) do
|
||||
local memo = obj.getMemo()
|
||||
if memo then
|
||||
local decoded = JSON.decode(memo) or {}
|
||||
if decoded.type == type then
|
||||
table.insert(objList, obj)
|
||||
end
|
||||
end
|
||||
end
|
||||
return objList
|
||||
end
|
||||
|
||||
---------------------------------------------------------
|
||||
-- chaos token drawing
|
||||
---------------------------------------------------------
|
||||
@ -963,8 +1014,12 @@ function spawnHelperObject(name, position, rotation, color)
|
||||
for _, obj in ipairs(sourceBag.getData().ContainedObjects) do
|
||||
if obj["Nickname"] == name then
|
||||
spawnTable.data = obj
|
||||
|
||||
-- this set the memo to identify the object at a later point (type = name without spaces)
|
||||
if color then
|
||||
spawnTable.data["Memo"] = "{\"matColor\":\"" .. color .. "\",\"type\":\"" .. name:gsub("%s+", "") .. "\"}"
|
||||
end
|
||||
|
||||
spawnTable.callback_function = function(spawnedObj)
|
||||
Wait.time(function() spawnedObj.setLock(true) end, 2)
|
||||
end
|
||||
|
@ -1,12 +1,12 @@
|
||||
do
|
||||
local NavigationOverlayApi = {}
|
||||
local HANDLER_GUID = "797ede"
|
||||
|
||||
-- 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)
|
||||
getObjectFromGUID(HANDLER_GUID).call("copyVisibility", {
|
||||
local handler = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "NavigationOverlayHandler"})
|
||||
handler.call("copyVisibility", {
|
||||
startColor = startColor,
|
||||
targetColor = targetColor
|
||||
})
|
||||
@ -15,7 +15,8 @@ do
|
||||
-- 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)
|
||||
getObjectFromGUID(HANDLER_GUID).call("cycleVisibility", playerColor)
|
||||
local handler = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "NavigationOverlayHandler"})
|
||||
handler.call("cycleVisibility", playerColor)
|
||||
end
|
||||
|
||||
return NavigationOverlayApi
|
||||
|
@ -1,18 +1,16 @@
|
||||
do
|
||||
local PlayAreaApi = { }
|
||||
local PLAY_AREA_GUID = "721ba2"
|
||||
local INVESTIGATOR_COUNTER_GUID = "f182ee"
|
||||
|
||||
-- Returns the current value of the investigator counter from the playmat
|
||||
---@return Integer. Number of investigators currently set on the counter
|
||||
PlayAreaApi.getInvestigatorCount = function()
|
||||
return getObjectFromGUID(INVESTIGATOR_COUNTER_GUID).getVar("val")
|
||||
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "InvestigatorCounter"}).getVar("val")
|
||||
end
|
||||
|
||||
-- Updates the current value of the investigator counter from the playmat
|
||||
---@param count Number of investigators to set on the counter
|
||||
PlayAreaApi.setInvestigatorCount = function(count)
|
||||
return getObjectFromGUID(INVESTIGATOR_COUNTER_GUID).call("updateVal", count)
|
||||
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "InvestigatorCounter"}).call("updateVal", count)
|
||||
end
|
||||
|
||||
-- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain
|
||||
@ -21,85 +19,85 @@ do
|
||||
---@param playerColor 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
|
||||
PlayAreaApi.shiftContentsUp = function(playerColor)
|
||||
return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsUp", playerColor)
|
||||
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("shiftContentsUp", playerColor)
|
||||
end
|
||||
|
||||
PlayAreaApi.shiftContentsDown = function(playerColor)
|
||||
return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsDown", playerColor)
|
||||
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("shiftContentsDown", playerColor)
|
||||
end
|
||||
|
||||
PlayAreaApi.shiftContentsLeft = function(playerColor)
|
||||
return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsLeft", playerColor)
|
||||
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("shiftContentsLeft", playerColor)
|
||||
end
|
||||
|
||||
PlayAreaApi.shiftContentsRight = function(playerColor)
|
||||
return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsRight", playerColor)
|
||||
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("shiftContentsRight", playerColor)
|
||||
end
|
||||
|
||||
-- Reset the play area's tracking of which cards have had tokens spawned.
|
||||
PlayAreaApi.resetSpawnedCards = function()
|
||||
return getObjectFromGUID(PLAY_AREA_GUID).call("resetSpawnedCards")
|
||||
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("resetSpawnedCards")
|
||||
end
|
||||
|
||||
-- Event to be called when the current scenario has changed.
|
||||
---@param scenarioName Name of the new scenario
|
||||
PlayAreaApi.onScenarioChanged = function(scenarioName)
|
||||
getObjectFromGUID(PLAY_AREA_GUID).call("onScenarioChanged", scenarioName)
|
||||
Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).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 matchTypes Boolean Whether snap points should only snap for the matching card types.
|
||||
PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)
|
||||
getObjectFromGUID(PLAY_AREA_GUID).call("setLimitSnapsByType", matchCardTypes)
|
||||
Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("setLimitSnapsByType", matchCardTypes)
|
||||
end
|
||||
|
||||
-- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged
|
||||
-- cards before they're destroyed by entering the container
|
||||
PlayAreaApi.tryObjectEnterContainer = function(container, object)
|
||||
getObjectFromGUID(PLAY_AREA_GUID).call("tryObjectEnterContainer",
|
||||
Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("tryObjectEnterContainer",
|
||||
{ container = container, object = object })
|
||||
end
|
||||
|
||||
-- counts the VP on locations in the play area
|
||||
PlayAreaApi.countVP = function()
|
||||
return getObjectFromGUID(PLAY_AREA_GUID).call("countVP")
|
||||
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("countVP")
|
||||
end
|
||||
|
||||
-- highlights all locations in the play area without metadata
|
||||
---@param state Boolean True if highlighting should be enabled
|
||||
PlayAreaApi.highlightMissingData = function(state)
|
||||
return getObjectFromGUID(PLAY_AREA_GUID).call("highlightMissingData", state)
|
||||
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("highlightMissingData", state)
|
||||
end
|
||||
|
||||
-- highlights all locations in the play area with VP
|
||||
---@param state Boolean True if highlighting should be enabled
|
||||
PlayAreaApi.highlightCountedVP = function(state)
|
||||
return getObjectFromGUID(PLAY_AREA_GUID).call("highlightCountedVP", state)
|
||||
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("highlightCountedVP", state)
|
||||
end
|
||||
|
||||
-- Checks if an object is in the play area (returns true or false)
|
||||
PlayAreaApi.isInPlayArea = function(object)
|
||||
return getObjectFromGUID(PLAY_AREA_GUID).call("isInPlayArea", object)
|
||||
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("isInPlayArea", object)
|
||||
end
|
||||
|
||||
PlayAreaApi.getSurface = function()
|
||||
return getObjectFromGUID(PLAY_AREA_GUID).getCustomObject().image
|
||||
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).getCustomObject().image
|
||||
end
|
||||
|
||||
PlayAreaApi.updateSurface = function(url)
|
||||
return getObjectFromGUID(PLAY_AREA_GUID).call("updateSurface", url)
|
||||
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("updateSurface", url)
|
||||
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
|
||||
PlayAreaApi.updateLocations = function(args)
|
||||
getObjectFromGUID(PLAY_AREA_GUID).call("updateLocations", args)
|
||||
Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("updateLocations", args)
|
||||
end
|
||||
|
||||
PlayAreaApi.getCustomDataHelper = function()
|
||||
return getObjectFromGUID(PLAY_AREA_GUID).getVar("customDataHelper")
|
||||
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).getVar("customDataHelper")
|
||||
end
|
||||
|
||||
return PlayAreaApi
|
||||
|
@ -9,7 +9,8 @@ do
|
||||
}
|
||||
|
||||
local function playTriggerEffect(index)
|
||||
getObjectsWithTag("SoundCube")[1].AssetBundle.playTriggerEffect(index)
|
||||
local SoundCube = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "SoundCube"})
|
||||
SoundCube.AssetBundle.playTriggerEffect(index)
|
||||
end
|
||||
|
||||
-- plays the by name requested sound
|
||||
|
@ -11,11 +11,10 @@ local highlightMissing = false
|
||||
local highlightCounted = false
|
||||
|
||||
local TRASHCAN
|
||||
local TRASHCAN_GUID = "70b9f6"
|
||||
|
||||
-- button creation when loading the game
|
||||
function onLoad()
|
||||
TRASHCAN = getObjectFromGUID(TRASHCAN_GUID)
|
||||
TRASHCAN = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "Trash"})
|
||||
|
||||
-- index 0: VP - "Display"
|
||||
local buttonParameters = {}
|
||||
|
@ -1,18 +1,19 @@
|
||||
do
|
||||
local VictoryDisplayApi = {}
|
||||
local VD_GUID = "6ccd6d"
|
||||
|
||||
-- triggers an update of the Victory count
|
||||
---@param delay Number Delay in seconds after which the update call is executed
|
||||
VictoryDisplayApi.update = function(delay)
|
||||
getObjectFromGUID(VD_GUID).call("startUpdate", delay)
|
||||
local VictoryDisplay = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "VictoryDisplay"})
|
||||
VictoryDisplay.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
|
||||
VictoryDisplayApi.placeCard = function(object)
|
||||
if object ~= nil and object.tag == "Card" then
|
||||
getObjectFromGUID(VD_GUID).call("placeCard", object)
|
||||
local VictoryDisplay = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "VictoryDisplay"})
|
||||
VictoryDisplay.call("placeCard", object)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,29 +1,31 @@
|
||||
do
|
||||
local AllCardsBagApi = {}
|
||||
local ALL_CARDS_BAG_GUID = "15bb07"
|
||||
|
||||
-- Returns a specific card from the bag, based on ArkhamDB ID
|
||||
-- @param table:
|
||||
-- id: String ID of the card to retrieve
|
||||
-- @return: If the indexes are still being constructed, an empty table is
|
||||
---@param id table String ID of the card to retrieve
|
||||
---@return table table
|
||||
-- If the indexes are still being constructed, an empty table is
|
||||
-- returned. Otherwise, a single table with the following fields
|
||||
-- cardData: TTS object data, suitable for spawning the card
|
||||
-- cardMetadata: Table of parsed metadata
|
||||
AllCardsBagApi.getCardById = function(id)
|
||||
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardById", {id = id})
|
||||
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
|
||||
return AllCardsBag.call("getCardById", {id = id})
|
||||
end
|
||||
|
||||
-- Gets a random basic weakness from the bag. Once a given ID has been returned
|
||||
-- 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: String ID of the selected weakness.
|
||||
---@return id String ID of the selected weakness.
|
||||
AllCardsBagApi.getRandomWeaknessId = function()
|
||||
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getRandomWeaknessId")
|
||||
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
|
||||
return AllCardsBag.call("getRandomWeaknessId")
|
||||
end
|
||||
|
||||
AllCardsBagApi.isIndexReady = function()
|
||||
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("isIndexReady")
|
||||
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
|
||||
return AllCardsBag.call("isIndexReady")
|
||||
end
|
||||
|
||||
-- Called by Hotfix bags when they load. If we are still loading indexes, then
|
||||
@ -32,40 +34,44 @@ do
|
||||
-- called once indexing is complete it means the hotfix bag has been added
|
||||
-- later, and we should rebuild the index to integrate the hotfix bag.
|
||||
AllCardsBagApi.rebuildIndexForHotfix = function()
|
||||
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("rebuildIndexForHotfix")
|
||||
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
|
||||
return AllCardsBag.call("rebuildIndexForHotfix")
|
||||
end
|
||||
|
||||
-- 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
|
||||
-- exact 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 getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardsByName", {name = name, exact = exact})
|
||||
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
|
||||
return AllCardsBag.call("getCardsByName", {name = name, exact = exact})
|
||||
end
|
||||
|
||||
AllCardsBagApi.isBagPresent = function()
|
||||
return getObjectFromGUID(ALL_CARDS_BAG_GUID) and true
|
||||
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
|
||||
return AllCardsBag and true
|
||||
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)
|
||||
-- upgraded: 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: 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
|
||||
AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded)
|
||||
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardsByClassAndLevel", {class = class, upgraded = upgraded})
|
||||
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
|
||||
return AllCardsBag.call("getCardsByClassAndLevel", {class = class, upgraded = upgraded})
|
||||
end
|
||||
|
||||
AllCardsBagApi.getCardsByCycle = function(cycle)
|
||||
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardsByCycle", cycle)
|
||||
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
|
||||
return AllCardsBag.call("getCardsByCycle", cycle)
|
||||
end
|
||||
|
||||
AllCardsBagApi.getUniqueWeaknesses = function()
|
||||
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getUniqueWeaknesses")
|
||||
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
|
||||
return AllCardsBag.call("getUniqueWeaknesses")
|
||||
end
|
||||
|
||||
return AllCardsBagApi
|
||||
|
@ -7,7 +7,7 @@ local validCountItemList = {
|
||||
["Clue"] = 1,
|
||||
[""] = 1
|
||||
}
|
||||
local trashGUID = "70b9f6"
|
||||
local MATCOLOR, TRASH
|
||||
exposedValue = 0
|
||||
|
||||
function onLoad()
|
||||
@ -21,6 +21,9 @@ function onLoad()
|
||||
font_color = { 0, 0, 0 },
|
||||
font_size = 2000
|
||||
})
|
||||
-- set MATCOLOR based on memo
|
||||
MATCOLOR = JSON.decode(self.getMemo()).matColor
|
||||
TRASH = Global.call("getObjectFromMemo", {matColor = MATCOLOR, type = "Trash"})
|
||||
loopID = Wait.time(countItems, 1, -1)
|
||||
end
|
||||
|
||||
@ -79,7 +82,7 @@ function clueRemovalCoroutine()
|
||||
for k = 1, 10 do
|
||||
coroutine.yield(0)
|
||||
end
|
||||
getObjectFromGUID(trashGUID).putObject(entry.hit_object)
|
||||
TRASH.putObject(entry.hit_object)
|
||||
end
|
||||
end
|
||||
return 1
|
||||
|
@ -61,7 +61,7 @@ local ENCOUNTER_DISCARD_POSITION = { x = -3.85, y = 1.5, z = 10.38}
|
||||
-- global variable so it can be reset by the Clean Up Helper
|
||||
activeInvestigatorId = "00000"
|
||||
|
||||
local MATCOLOR, TRASHCAN, STAT_TRACKER, RESOURCE_COUNTER
|
||||
local MATCOLOR, TRASHCAN, STAT_TRACKER, RESOURCE_COUNTER, CLUE_COUNTER, CLUE_CLICKER
|
||||
local isDrawButtonVisible = false
|
||||
|
||||
-- global variable to report "Dream-Enhancing Serum" status
|
||||
@ -82,9 +82,11 @@ function onLoad(save_state)
|
||||
-- set MATCOLOR based on memo
|
||||
MATCOLOR = JSON.decode(self.getMemo()).matColor
|
||||
|
||||
TRASHCAN = getObjectFromMemo(MATCOLOR, "Trash")
|
||||
STAT_TRACKER = getObjectFromMemo(MATCOLOR, "InvestigatorSkillTracker")
|
||||
RESOURCE_COUNTER = getObjectFromMemo(MATCOLOR, "ResourceCounter")
|
||||
TRASHCAN = Global.call("getObjectFromMemo", {matColor = MATCOLOR, type = "Trash"})
|
||||
STAT_TRACKER = Global.call("getObjectFromMemo", {matColor = MATCOLOR, type = "InvestigatorSkillTracker"})
|
||||
RESOURCE_COUNTER = Global.call("getObjectFromMemo", {matColor = MATCOLOR, type = "ResourceCounter"})
|
||||
CLUE_COUNTER = Global.call("getObjectFromMemo", {matColor = MATCOLOR, type = "ClueCounter"})
|
||||
CLUE_CLICKER = Global.call("getObjectFromMemo", {matColor = MATCOLOR, type = "ClickableClueCounter"})
|
||||
|
||||
-- button creation
|
||||
for i = 1, 6 do
|
||||
@ -220,27 +222,6 @@ function round(num, numDecimalPlaces)
|
||||
return math.floor(num * mult + 0.5) / mult
|
||||
end
|
||||
|
||||
-- gets the first object that matches the provided information
|
||||
---@param matColor String Color of the playermat
|
||||
---@param type String Object to look for (usually name without spaces)
|
||||
function getObjectFromMemo(matColor, type)
|
||||
if matColor == nil or type == nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
for _, obj in ipairs(getObjects()) do
|
||||
local memo = obj.getMemo()
|
||||
if memo then
|
||||
local decoded = JSON.decode(memo) or {}
|
||||
if decoded.matColor == matColor and decoded.type == type then
|
||||
return obj
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
---------------------------------------------------------
|
||||
-- Discard buttons
|
||||
---------------------------------------------------------
|
||||
@ -603,7 +584,7 @@ function changeColor(clickedByColor)
|
||||
-- show the option dialog for color selection to the player that triggered this
|
||||
Player[clickedByColor].showOptionsDialog("Select a new color:", colorList, _, function(color)
|
||||
-- update the color of the hand zone
|
||||
local handZone = getObjectFromMemo(MATCOLOR, "HandZone")
|
||||
local handZone = Global.call("getObjectFromMemo", {matColor = MATCOLOR, "HandZone"})
|
||||
handZone.setValue(color)
|
||||
|
||||
-- if the seated player clicked this, reseat him to the new color
|
||||
@ -888,8 +869,6 @@ end
|
||||
-- Spawns / destroys a clickable clue counter for this playmat with the correct amount of clues
|
||||
---@param showCounter Boolean Whether the clickable clue counter should be present
|
||||
function clickableClues(showCounter)
|
||||
local CLUE_COUNTER = getObjectFromMemo(MATCOLOR, "ClueCounter")
|
||||
local CLUE_CLICKER = getObjectFromMemo(MATCOLOR, "ClickableClueCounter")
|
||||
local clickerPos = CLUE_CLICKER.getPosition()
|
||||
local clueCount = 0
|
||||
|
||||
@ -925,9 +904,6 @@ end
|
||||
|
||||
-- removes all clues (moving tokens to the trash and setting counters to 0)
|
||||
function removeClues()
|
||||
local CLUE_COUNTER = getObjectFromMemo(MATCOLOR, "ClueCounter")
|
||||
local CLUE_CLICKER = getObjectFromMemo(MATCOLOR, "ClickableClueCounter")
|
||||
|
||||
CLUE_COUNTER.call("removeAllClues")
|
||||
CLUE_CLICKER.call("updateVal", 0)
|
||||
end
|
||||
@ -938,10 +914,8 @@ function getClueCount(useClickableCounters)
|
||||
local count = 0
|
||||
|
||||
if useClickableCounters then
|
||||
local CLUE_CLICKER = getObjectFromMemo(MATCOLOR, "ClickableClueCounter")
|
||||
count = tonumber(CLUE_CLICKER.getVar("val"))
|
||||
else
|
||||
local CLUE_COUNTER = getObjectFromMemo(MATCOLOR, "ClueCounter")
|
||||
count = tonumber(CLUE_COUNTER.getVar("exposedValue"))
|
||||
end
|
||||
return count
|
||||
|
@ -2,27 +2,6 @@ do
|
||||
local PlaymatApi = { }
|
||||
local internal = { }
|
||||
|
||||
-- gets the first object that matches the provided information
|
||||
---@param matColor String Color of the playermat
|
||||
---@param type String Object to look for (usually name without spaces)
|
||||
internal.getObjectFromMemo = function(matColor, type)
|
||||
if matColor == nil or type == nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
for _, obj in ipairs(getObjects()) do
|
||||
local memo = obj.getMemo()
|
||||
if memo then
|
||||
local decoded = JSON.decode(memo) or {}
|
||||
if decoded.matColor == matColor and decoded.type == type then
|
||||
return obj
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Returns the color of the by position requested playermat as string
|
||||
---@param startPos Table Position of the search, table get's roughly cut into 4 quarters to assign a playermat
|
||||
PlaymatApi.getMatColorByPosition = function(startPos)
|
||||
@ -44,7 +23,7 @@ do
|
||||
-- Returns the color of the player's hand that is seated next to the playermat
|
||||
---@param matColor String Color of the playermat
|
||||
PlaymatApi.getPlayerColor = function(matColor)
|
||||
local mat = internal.getObjectFromMemo(matColor, "Playermat")
|
||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
||||
return mat.getVar("playerColor")
|
||||
end
|
||||
|
||||
@ -62,21 +41,21 @@ do
|
||||
-- Returns the result of a cast in the specificed playermat's area
|
||||
---@param matColor String Color of the playermat
|
||||
PlaymatApi.searchPlaymat = function(matColor)
|
||||
local mat = internal.getObjectFromMemo(matColor, "Playermat")
|
||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
||||
return mat.call("searchAroundSelf")
|
||||
end
|
||||
|
||||
-- Returns if there is the card "Dream-Enhancing Serum" on the requested playermat
|
||||
---@param matColor String Color of the playermat
|
||||
PlaymatApi.isDES = function(matColor)
|
||||
local mat = internal.getObjectFromMemo(matColor, "Playermat")
|
||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
||||
return mat.getVar("isDES")
|
||||
end
|
||||
|
||||
-- Returns the draw deck of the requested playmat
|
||||
---@param matColor String Color of the playermat
|
||||
PlaymatApi.getDrawDeck = function(matColor)
|
||||
local mat = internal.getObjectFromMemo(matColor, "Playermat")
|
||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
||||
mat.call("getDrawDiscardDecks")
|
||||
return mat.getVar("drawDeck")
|
||||
end
|
||||
@ -84,7 +63,7 @@ do
|
||||
-- Returns the position of the discard pile of the requested playmat
|
||||
---@param matColor String Color of the playermat
|
||||
PlaymatApi.getDiscardPosition = function(matColor)
|
||||
local mat = internal.getObjectFromMemo(matColor, "Playermat")
|
||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
||||
return mat.call("returnGlobalDiscardPosition")
|
||||
end
|
||||
|
||||
@ -92,14 +71,14 @@ do
|
||||
---@param localPos Table Local position to be transformed
|
||||
---@param matColor String Color of the playermat
|
||||
PlaymatApi.transformLocalPosition = function(localPos, matColor)
|
||||
local mat = internal.getObjectFromMemo(matColor, "Playermat")
|
||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
||||
return mat.positionToWorld(localPos)
|
||||
end
|
||||
|
||||
-- Returns the rotation of the requested playmat
|
||||
---@param matColor String Color of the playermat
|
||||
PlaymatApi.returnRotation = function(matColor)
|
||||
local mat = internal.getObjectFromMemo(matColor, "Playermat")
|
||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
||||
return mat.getRotation()
|
||||
end
|
||||
|
||||
@ -107,14 +86,14 @@ do
|
||||
---@param matColor String Color of the playermat
|
||||
---@param playerColor String Color of the calling player (for messages)
|
||||
PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)
|
||||
local mat = internal.getObjectFromMemo(matColor, "Playermat")
|
||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
||||
return mat.call("doUpkeepFromHotkey", playerColor)
|
||||
end
|
||||
|
||||
-- Returns the active investigator id
|
||||
---@param matColor String Color of the playermat
|
||||
PlaymatApi.returnInvestigatorId = function(matColor)
|
||||
local mat = internal.getObjectFromMemo(matColor, "Playermat")
|
||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
||||
return mat.getVar("activeInvestigatorId")
|
||||
end
|
||||
|
||||
@ -180,7 +159,7 @@ do
|
||||
|
||||
-- Returns the resource counter amount for the requested playermat
|
||||
PlaymatApi.getResourceCount = function(matColor)
|
||||
local mat = internal.getObjectFromMemo(matColor, "Playermat")
|
||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
||||
return mat.call("getResourceCount")
|
||||
end
|
||||
|
||||
@ -198,7 +177,7 @@ do
|
||||
end
|
||||
|
||||
PlaymatApi.updateClueClicker = function(matColor, val)
|
||||
return internal.getObjectFromMemo(matColor, "ClickableClueCounter").call("updateVal", val)
|
||||
return Global.call("getObjectFromMemo", {matColor = matColor, type = "ClickableClueCounter"}).call("updateVal", val)
|
||||
end
|
||||
|
||||
-- Convenience function to look up a mat's object by color, or get all mats.
|
||||
@ -207,16 +186,16 @@ do
|
||||
---@return: Array of playermat objects. If a single mat is requested, will return a single-element
|
||||
-- array to simplify processing by consumers.
|
||||
internal.getMatForColor = function(matColor)
|
||||
local targetMat = internal.getObjectFromMemo(matColor, "Playermat")
|
||||
local targetMat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
||||
if targetMat != nil then
|
||||
return { targetMatGuid }
|
||||
end
|
||||
if matColor == "All" then
|
||||
return {
|
||||
internal.getObjectFromMemo("White", "Playermat"),
|
||||
internal.getObjectFromMemo("Orange", "Playermat"),
|
||||
internal.getObjectFromMemo("Green", "Playermat"),
|
||||
internal.getObjectFromMemo("Red", "Playermat"),
|
||||
Global.call("getObjectFromMemo", {matColor = White, type = "Playermat"}),
|
||||
Global.call("getObjectFromMemo", {matColor = Orange, type = "Playermat"}),
|
||||
Global.call("getObjectFromMemo", {matColor = Green, type = "Playermat"}),
|
||||
Global.call("getObjectFromMemo", {matColor = Red, type = "Playermat"})
|
||||
}
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user